commit | 934c867b3727fe231100715d04e363992ca5ea38 | [log] [tgz] |
---|---|---|
author | Paul Gier <paul.gier@datastax.com> | Fri Aug 12 11:34:39 2022 -0500 |
committer | GitHub <noreply@github.com> | Fri Aug 12 11:34:39 2022 -0500 |
tree | 2875932757e6bf692a68ddcf0462c5d6f8d05260 | |
parent | c2476193159f89a92f4da0be50be1e3472616f19 [diff] |
[oauth2] Remove oauth2 go.mod and go.sum (#802) * remove oauth2 module This removes the module definition in the oauth2 subdirectory. Since the oauth2 module is not released independently of the main module, it can/should be treated as a normal module subdirectory. Signed-off-by: Paul Gier <paul.gier@datastax.com> * update tests for newer golang oauth2 dependency Signed-off-by: Paul Gier <paul.gier@datastax.com> * oauth2: add note to readme about possible module error Signed-off-by: Paul Gier <paul.gier@datastax.com> Signed-off-by: Paul Gier <paul.gier@datastax.com> ### Motivation When the oauth2 sub-directory was added in PR #313 there wasn't any justification given (AFAICT) for creating a separate sub-module instead of just treating the oauth2 sources as a normal directory. Since the oauth2 module does not have a separate release cycle, treating it as a sub-module just adds unnecessary complexity. ### Modifications Removed `go.mod` and `go.sum` from the oauth2 sub-directory. Updated the main `go.mod` and `go.sum` to included the necessary dependencies. The main module contained a newer version of `golang.org/x/oauth2` dependency than the oauth2 sub-module, so I had to update some of the tests to match the output of the newer dependency. This type of dependency mismatch will be avoided in the future using a single module defined in the root directory.
A Go client library for the Apache Pulsar project.
This projects is developing a pure-Go client library for Pulsar that does not depend on the C++ Pulsar library.
Once feature parity and stability are reached, this will supersede the current CGo based library.
Check the Projects page at https://github.com/apache/pulsar-client-go/projects for tracking the status and the progress.
Import the client library:
import "github.com/apache/pulsar-client-go/pulsar"
Create a Producer:
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://localhost:6650",
})
defer client.Close()
producer, err := client.CreateProducer(pulsar.ProducerOptions{
Topic: "my-topic",
})
_, err = producer.Send(context.Background(), &pulsar.ProducerMessage{
Payload: []byte("hello"),
})
defer producer.Close()
if err != nil {
fmt.Println("Failed to publish message", err)
} else {
fmt.Println("Published message")
}
Create a Consumer:
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://localhost:6650",
})
defer client.Close()
consumer, err := client.Subscribe(pulsar.ConsumerOptions{
Topic: "my-topic",
SubscriptionName: "my-sub",
Type: pulsar.Shared,
})
defer consumer.Close()
msg, err := consumer.Receive(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("Received message msgId: %#v -- content: '%s'\n",
msg.ID(), string(msg.Payload()))
Create a Reader:
client, err := pulsar.NewClient(pulsar.ClientOptions{URL: "pulsar://localhost:6650"})
if err != nil {
log.Fatal(err)
}
defer client.Close()
reader, err := client.CreateReader(pulsar.ReaderOptions{
Topic: "topic-1",
StartMessageID: pulsar.EarliestMessageID(),
})
if err != nil {
log.Fatal(err)
}
defer reader.Close()
for reader.HasNext() {
msg, err := reader.Next(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("Received message msgId: %#v -- content: '%s'\n",
msg.ID(), string(msg.Payload()))
}
Build the sources:
go build ./pulsar
Run the unit tests:
./docker-ci.sh
Contributions are welcomed and greatly appreciated. See CONTRIBUTING.md for details on submitting patches and the contribution workflow.
Name | Scope | |||
---|---|---|---|---|
users@pulsar.apache.org | User-related discussions | Subscribe | Unsubscribe | Archives |
dev@pulsar.apache.org | Development-related discussions | Subscribe | Unsubscribe | Archives |
Pulsar slack channel #dev-go
at https://apache-pulsar.slack.com/
You can self-register at https://apache-pulsar.herokuapp.com/
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
If you've upgraded from a previous version of this library, you may run into an ‘ambigous import’ error when building.
github.com/apache/pulsar-client-go/oauth2: ambiguous import: found package github.com/apache/pulsar-client-go/oauth2 in multiple modules
The fix for this is to make sure you don't have any references in your go.mod
file to the old oauth2 module path. So remove any lines similar to the following, and then run go mod tidy
.
github.com/apache/pulsar-client-go/oauth2 v0.0.0-20220630195735-e95cf0633348 // indirect