Skip to content
Apache Pulsar Go Client Library
Go Shell Dockerfile
Branch: master
Clone or download
wolfstudy and jiazhai Check `golint`, `gofmt` and `go import` for project (#55)
* code format

Signed-off-by: xiaolong.ran <ranxiaolong716@gmail.com>

* fix seek logic

Signed-off-by: xiaolong.ran <ranxiaolong716@gmail.com>
Latest commit a615761 Aug 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add github issues template (#18) Jul 11, 2019
examples Check `golint`, `gofmt` and `go import` for project (#55) Aug 15, 2019
integration-tests Added token auth provider May 9, 2019
perf Fix gofmt and golint issues Jul 26, 2019
pkg Check `golint`, `gofmt` and `go import` for project (#55) Aug 15, 2019
pulsar Check `golint`, `gofmt` and `go import` for project (#55) Aug 15, 2019
util Check `golint`, `gofmt` and `go import` for project (#55) Aug 15, 2019
.gitignore Ignore some files that are automatically generated in the project (#41) Aug 5, 2019
.golangci.yml
.header Improve README.md and add CONTRIBUTING.md file (#51) Aug 13, 2019
CONTRIBUTING.md [Issue:53] Fix concurrent map write (#54) Aug 14, 2019
Dockerfile Fix the openjdk-8-jre-headless can't download Aug 1, 2019
LICENSE Removed non-needed section in LICENSE (#8) May 15, 2019
NOTICE Added license headers May 6, 2019
README.md Improve README.md and add CONTRIBUTING.md file (#51) Aug 13, 2019
docker-ci.sh Added scripts to run unit tests (#6) May 15, 2019
go.mod Impl consumer logic for go client Jul 15, 2019
go.sum Impl consumer logic for go client Jul 15, 2019
pulsar-test-service-start.sh Added scripts to start test service May 8, 2019
pulsar-test-service-stop.sh Added scripts to start test service May 8, 2019
run-ci.sh Fix test killed with quit: ran too long (#50) Aug 9, 2019

README.md

GoDoc Go Report Card Language LICENSE

Apache Pulsar Go Client Library

A Go client library for the Apache Pulsar project.

Goal

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.

Requirements

  • Go 1.11+

Status

Check the Projects page at https://github.com/apache/pulsar-client-go/projects for tracking the status and the progress.

Usage

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)
}
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()))

Contributing

Contributions are welcomed and greatly appreciated. See CONTRIBUTING.md for details on submitting patches and the contribution workflow.

Contact

Mailing lists
Name Scope
users@pulsar.apache.org User-related discussions Subscribe Unsubscribe Archives
dev@pulsar.apache.org Development-related discussions Subscribe Unsubscribe Archives
Slack

Pulsar slack channel #dev-go at https://apache-pulsar.slack.com/

You can self-register at https://apache-pulsar.herokuapp.com/

License

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

You can’t perform that action at this time.