{"id":27969195,"url":"https://github.com/future-architect/fluentdpub","last_synced_at":"2025-05-07T21:08:59.210Z","repository":{"id":57507508,"uuid":"219708200","full_name":"future-architect/fluentdpub","owner":"future-architect","description":"publish only fluentd backend for gocloud.dev/pubsub","archived":false,"fork":false,"pushed_at":"2020-01-17T00:22:59.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-07T21:08:56.207Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/future-architect.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":"2019-11-05T09:37:08.000Z","updated_at":"2020-01-17T00:23:01.000Z","dependencies_parsed_at":"2022-09-26T18:31:33.475Z","dependency_job_id":null,"html_url":"https://github.com/future-architect/fluentdpub","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Ffluentdpub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Ffluentdpub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Ffluentdpub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Ffluentdpub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/future-architect","download_url":"https://codeload.github.com/future-architect/fluentdpub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954409,"owners_count":21830905,"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-05-07T21:08:58.597Z","updated_at":"2025-05-07T21:08:59.199Z","avatar_url":"https://github.com/future-architect.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fluentdpub - fluentd backend for gocloud.dev's pubsub\n\n[![GoDoc](https://godoc.org/github.com/future-architect/fluentdpub?status.svg)](https://godoc.org/github.com/future-architect/fluentdpub)\n\n`fluentdpub` is a backend for gocloud.dev. It only supports publisher (topic) side.\n\nIt supports two style API like gocloud.dev, common URL constructor and Fluentd specific constructor.\n\n## Common URL Constructor\n\nAfter importing `fluentdpub` package, you can open bia `pubsub.OpenTopic()` function.\n`fluentd://` URL only contains tag prefix.\n\nUpstream Fluentd server is specified by ``FLUENTD_UPSTREAM_URL`` env var.\n\n```go\nimport (\n\t\"context\"\n\n\t\"gocloud.dev/pubsub\"\n\t_ \"github.com/future-architect/fluentdpub\"\n)\n\n// pubsub.OpenTopic creates a *pubsub.Topic from a URL.\n// This URL will Dial the Fluentd server at the URL in the environment variable\n// FLUENTD_UPSTREAM_URL and send messages with tag \"example.tag\".\ntopic, err := pubsub.OpenTopic(ctx, \"fluentd://stg.my-app\")\nif err != nil {\n\treturn err\n}\nerr = topic.Send(ctx, \u0026pubsub.Message{\n    // Fluentd doesn't have main contant named body\n    // fluentdpub embeds body into metadata.\n    // Default key of body is \"message\"\n\tBody: []byte(\"Hello, World!\\n\"),\n\t// Metadata is optional and can be nil.\n\tMetadata: map[string]string{\n\t\t// These are examples of metadata.\n\t\t// There is nothing special about the key names.\n\t\t\"language\":   \"en\",\n\t\t\"importance\": \"high\",\n\t},\n})\n\ndefer topic.Shutdown(ctx)\n```\n\n### Option\n\nURL can have two queries:\n\n- `bodykey` (default: `\"message\"`):\n      Message.Body content is stored into `Metadata` of this key.\n- `tagkey` (default: `\"tag\"`):\n      The Value in this key of `Metadata` is used as tag prefix.\n\n### Tag Name\n\nThere three locations you can specify tag.\n\n- `FLUENTD_UPSTREAM_URL`'s path name\n- URL's host name\n- Metadata's tag value (specified by `tagkey` parameter or `\"tag\"` by default)\n\nIf `FLUENTD_UPSTREAM_URL` is `\"tcp://localhost:24224/prod\"` URL is `fluentd://my-app` and the message to send contains `\"tag\"` Metadata with the value `\"error\"`, log will be sent with `prod.my-app.error` tag. Empty element will be ignored (if `FLUENTD_UPSTREAM_URL` is `\"tcp://localhost:24224\"`, final tag will be `my-app.error`).\n\n## Fluentd Specific Constructor\n\nThe `fluentdpub.OpenTopic` constructor opens a Fluentd subject as a topic. You must first create an *fluent.Fluent to your Fluentd server instance.\n\n```go\nimport (\n\t\"context\"\n\n\t\"github.com/future-architect/fluentdpub\"\n)\n\n// pubsub.OpenTopic creates a *pubsub.Topic from a URL.\n// This URL will Dial the Fluentd server at the URL in the environment variable\n// FLUENTD_UPSTREAM_URL and send messages with tag \"example.tag\".\nf, err := fluent.New(fluent.Config{\n\tFluentHost: \"fluentd.example.com\",\n})\ntopic, err := fluentdpub.OpenTopic(f, \"prod.myapp\", fluentdpub.TopicOptions{})\nif err != nil {\n\treturn err\n}\nerr = topic.Send(context.Background(), \u0026pubsub.Message{\n    // Fluentd doesn't have main contant named body\n    // fluentdpub embeds body into metadata.\n    // Default key of body is \"message\"\n\tBody: []byte(\"Hello, World!\\n\"),\n\t// Metadata is optional and can be nil.\n\tMetadata: map[string]string{\n\t\t// These are examples of metadata.\n\t\t// There is nothing special about the key names.\n\t\t\"language\":   \"en\",\n\t\t\"importance\": \"high\",\n\t},\n})\n```\n\n### Option\n\nTopicOptions has two fields:\n\n- `BodyKey` (default: `\"message\"`):\n      Message.Body content is stored into `Metadata` of this key.\n- `TagKey` (default: `\"tag\"`):\n      The Value in this key of `Metadata` is used as tag prefix.\n\n### Tag Name\n\nThere two location you can specify tag.\n\n- URL's host name\n- Metadata's tag value (specified by `tagkey` parameter or `\"tag\"` by default)\n\nIf URL is `fluentd://prod.my-app` and the message to send contains `\"tag\"` Metadata with the value `\"error\"`, log will be sent with `prod.my-app.error` tag. If one of them is empty, non empty one is used.\n\n## License\n\nApache 2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Ffluentdpub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuture-architect%2Ffluentdpub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Ffluentdpub/lists"}