{"id":16265540,"url":"https://github.com/bruth/go-pulsar-ws","last_synced_at":"2025-04-04T02:33:16.981Z","repository":{"id":57541704,"uuid":"132463961","full_name":"bruth/go-pulsar-ws","owner":"bruth","description":"Go client for Apache Pulsar using the Websocket protocol.","archived":false,"fork":false,"pushed_at":"2018-05-07T13:53:38.000Z","size":6,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T00:51:30.651Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bruth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-07T13:23:43.000Z","updated_at":"2022-02-17T12:58:20.000Z","dependencies_parsed_at":"2022-09-09T02:50:15.960Z","dependency_job_id":null,"html_url":"https://github.com/bruth/go-pulsar-ws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fgo-pulsar-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fgo-pulsar-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fgo-pulsar-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fgo-pulsar-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bruth","download_url":"https://codeload.github.com/bruth/go-pulsar-ws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247111631,"owners_count":20885474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T17:09:36.706Z","updated_at":"2025-04-04T02:33:16.723Z","avatar_url":"https://github.com/bruth.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-pulsar-ws\n\n[![GoDoc](https://godoc.org/github.com/bruth/go-pulsar-ws?status.svg)](http://godoc.org/github.com/bruth/go-pulsar-ws)\n\nA Go client for [Apache Pulsar](https://pulsar.incubator.apache.org) using the [Websocket protocol](https://pulsar.incubator.apache.org/docs/latest/clients/WebSocket/).\n\n## Status\n\nCurrently, there is no official Go client using the [binary protocol], although the Pulsar team is working on a cgo-based implementation. This library was created as a temporary solution. Once an official solution comes out, I will likely not support this anymore.\n\n## Usage\n\n### Producer\n\n```go\n// Initialize a client passing the Pulsar Websocket endpoint.\nclient := pulsar.New(\"ws://localhost:8080/ws\")\n\n// Initialize a producer given a topic with an optional set of parameters.\n// Establishes a websocket connection.\nproducer, err := client.Producer(\"persistent/standalone/us-east/test\", nil)\nif err != nil {\n  log.Fatal(err)\n}\ndefer producer.Close()\n\nctx := context.Background()\nres, err := producer.Send(ctx, *pulsar.PublishMsg{\n  Payload: []byte(\"hello world!\"),\n})\nif err != nil {\n  log.Fatal(err)\n}\n\n// Print the resulting message id.\nlog.Print(res.MsgId)\n```\n\n### Consumer\n\n```go\nclient := pulsar.New(\"ws://localhost:8080/ws\")\n\nconsumer, err := client.Consumer(\"persistent/standalone/us-east/test\", \"my-sub\", nil)\nif err != nil {\n  log.Fatal(err)\n}\ndefer consumer.Close()\n\nctx := context.Background()\n\nfor {\n  msg, err := consumer.Receive(ctx)\n  if err != nil {\n    log.Fatal(err)\n  }\n\n  // Print message.\n  log.Print(string(msg.Payload))\n\n  // Ack once processed.\n  if err := consumer.Ack(ctx, msg); err != nil {\n    log.Fatal(err)\n  }\n}\n```\n\n### Reader\n\n```go\nclient := pulsar.New(\"ws://localhost:8080/ws\")\n\nreader, err := client.Reader(\"persistent/standalone/us-east/test\", pulsar.Params{\n  \"messageId\": \"earliest\",\n})\nif err != nil {\n  log.Fatal(err)\n}\ndefer reader.Close()\n\nctx := context.Background()\n\nfor {\n  msg, err := reader.Receive(ctx)\n  if err != nil {\n    log.Fatal(err)\n  }\n\n  // Print message.\n  log.Print(string(msg.Payload))\n\n  // Ack once processed.\n  if err := reader.Ack(ctx, msg); err != nil {\n    log.Fatal(err)\n  }\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruth%2Fgo-pulsar-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruth%2Fgo-pulsar-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruth%2Fgo-pulsar-ws/lists"}