{"id":26685437,"url":"https://github.com/goapt/nsqclient","last_synced_at":"2025-10-29T07:41:11.975Z","repository":{"id":37431062,"uuid":"138719293","full_name":"goapt/nsqclient","owner":"goapt","description":"nsq client for golang","archived":false,"fork":false,"pushed_at":"2023-05-19T09:57:26.000Z","size":65,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T10:16:00.195Z","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/goapt.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,"governance":null}},"created_at":"2018-06-26T09:58:47.000Z","updated_at":"2021-10-25T09:29:33.000Z","dependencies_parsed_at":"2023-07-13T18:18:18.834Z","dependency_job_id":null,"html_url":"https://github.com/goapt/nsqclient","commit_stats":null,"previous_names":["verystar/nsqclient"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fnsqclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fnsqclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fnsqclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goapt%2Fnsqclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goapt","download_url":"https://codeload.github.com/goapt/nsqclient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248591856,"owners_count":21130134,"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":"2025-03-26T10:16:03.505Z","updated_at":"2025-10-29T07:41:06.937Z","avatar_url":"https://github.com/goapt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nsqclient\nnsq client for golang\n\n\u003ca href=\"https://github.com/goapt/nsqclient/actions\"\u003e\u003cimg src=\"https://github.com/goapt/nsqclient/workflows/build/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/goapt/nsqclient\"\u003e\u003cimg src=\"https://codecov.io/gh/goapt/nsqclient/branch/master/graph/badge.svg\" alt=\"codecov\"\u003e\u003c/a\u003e\n\u003ca href=\"https://goreportcard.com/report/github.com/goapt/nsqclient\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/goapt/nsqclient\" alt=\"Go Report Card\n\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pkg.go.dev/github.com/goapt/nsqclient\"\u003e\u003cimg src=\"https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\" alt=\"GoDoc\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opensource.org/licenses/mit-license.php\" rel=\"nofollow\"\u003e\u003cimg src=\"https://badges.frapsoft.com/os/mit/mit.svg?v=103\"\u003e\u003c/a\u003e\n\n\n##  Connection\n```go\nnsqclient.Connect(map[string]Config{\n    \"default\": Config{\n        Host:     \"10.64.146.231\",\n        Port:     \"4150\",\n        InitSize: 10,\n        MaxSize:  10,\n    },\n    \"other\": Config{\n        Host:     \"10.64.146.22\",\n        Port:     \"4150\",\n        InitSize: 10,\n        MaxSize:  10,\n    },\n})\n```\n\n## Publish\n写入nsq为了方便进行单元测试，可以注入nsqclient.Producer接口，然后在单元测试使用mock的实现\n```go\n// default client\nnsq := nsqclient.NewProducer(\"default\")\nnsq.Publish(\"topic\",\"body\")\n\n//mock\nnsq := nsqclient.NewMockProducer(\"default\")\nnsq.Publish(\"topic\",\"body\")\n```\n\n## Consumer\n```go\n// default connect\nconsumer := \u0026nsqclient.NsqHandler{\n    Topic:   \"log\",\n    Channel: \"default\",\n    Size:   10,\n}\n\nconsumer.SetHandle(func(lg logger.ILogger, message *nsq.Message) error {\n    // something\n    return nil\n})\n\nnsqclient.Register(consumer, \"access_log\")\n\nnsqclient.Run(\"access_log\", ctx)\n\n// other connect\nconsumer := \u0026nsqclient.NsqHandler{\n    Connect: \"other\",\n    Topic:   \"log\",\n    Channel: \"default\",\n    Size:   10,\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoapt%2Fnsqclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoapt%2Fnsqclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoapt%2Fnsqclient/lists"}