{"id":13412621,"url":"https://github.com/italolelis/outboxer","last_synced_at":"2025-04-11T00:33:10.807Z","repository":{"id":34996594,"uuid":"168676539","full_name":"italolelis/outboxer","owner":"italolelis","description":"A library that implements the outboxer pattern in go","archived":false,"fork":false,"pushed_at":"2024-07-29T11:20:07.000Z","size":273,"stargazers_count":153,"open_issues_count":4,"forks_count":27,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:51:11.726Z","etag":null,"topics":["distributed-systems","go","resiliency"],"latest_commit_sha":null,"homepage":"","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/italolelis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["italolelis"]}},"created_at":"2019-02-01T09:50:13.000Z","updated_at":"2024-07-10T13:41:59.000Z","dependencies_parsed_at":"2024-05-06T12:27:22.765Z","dependency_job_id":"c8f8bb44-4e93-482b-9af6-6fcaff90a714","html_url":"https://github.com/italolelis/outboxer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italolelis%2Foutboxer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italolelis%2Foutboxer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italolelis%2Foutboxer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italolelis%2Foutboxer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/italolelis","download_url":"https://codeload.github.com/italolelis/outboxer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322773,"owners_count":21084336,"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":["distributed-systems","go","resiliency"],"created_at":"2024-07-30T20:01:26.886Z","updated_at":"2025-04-11T00:33:10.784Z","avatar_url":"https://github.com/italolelis.png","language":"Go","funding_links":["https://github.com/sponsors/italolelis"],"categories":["Distributed Systems","分布式系统","Relational Databases"],"sub_categories":["Advanced Console UIs","检索及分析资料库","Search and Analytic Databases","SQL 查询语句构建库"],"readme":"# Outboxer\n\n[![Build Status](https://github.com/italolelis/outboxer/workflows/Main/badge.svg)](https://github.com/italolelis/outboxer/actions)\n[![codecov](https://codecov.io/gh/italolelis/outboxer/branch/master/graph/badge.svg?token=8G6G1B3QE6)](https://codecov.io/gh/italolelis/outboxer)\n[![Go Report Card](https://goreportcard.com/badge/github.com/italolelis/outboxer)](https://goreportcard.com/report/github.com/italolelis/outboxer)\n[![GoDoc](https://godoc.org/github.com/italolelis/outboxer?status.svg)](https://godoc.org/github.com/italolelis/outboxer)\n\nOutboxer is a go library that implements the [outbox pattern](http://www.kamilgrzybek.com/design/the-outbox-pattern/).\n\n## Getting Started\n\nOutboxer simplifies the challenging work of orchestrating message reliability. Essentially we are trying to solve this question:\n\n\u003e How can producers reliably send messages when the broker/consumer is unavailable?\n\nIf you have a distributed system architecture and especially mainly deal \nwith [Event Driven Architecture](https://martinfowler.com/articles/201701-event-driven.html), you might \nwant to use *outboxer*.\n\nThe first thing to do is include the package in your project.\n\n```sh\ngo get github.com/italolelis/outboxer\n```\n\n### Usage\n\nLet's setup a simple example where you are using Google's `PubSub` and `Postgres` as your outbox pattern components:\n\n```go\nctx, cancel := context.WithCancel(context.Background())\ndefer cancel()\n\ndb, err := sql.Open(\"postgres\", os.Getenv(\"DS_DSN\"))\nif err != nil {\n    fmt.Printf(\"could not connect to amqp: %s\", err)\n    return\n}\n\n// we need to create a data store instance first\nds, err := postgres.WithInstance(ctx, db)\nif err != nil {\n    fmt.Printf(\"could not setup the data store: %s\", err)\n    return\n}\ndefer ds.Close()\n\n// we create an event stream passing the pusub connection\nclient, err := pubsub.NewClient(ctx, os.Getenv(\"GCP_PROJECT_ID\"))\nif err != nil {\n    fmt.Printf(\"failed to connect to gcp: %s\", err)\n    return\n}\n\nes := pubsubOut.New(client)\n\n// now we create an outboxer instance passing the data store and event stream\no, err := outboxer.New(\n    outboxer.WithDataStore(ds),\n    outboxer.WithEventStream(es),\n    outboxer.WithCheckInterval(1*time.Second),\n    outboxer.WithCleanupInterval(5*time.Second),\n    outboxer.WithCleanUpBefore(time.Now().AddDate(0, 0, -5)),\n)\nif err != nil {\n    fmt.Printf(\"could not create an outboxer instance: %s\", err)\n    return\n}\n\n// here we initialize the outboxer checks and cleanup go rotines\no.Start(ctx)\ndefer o.Stop()\n\n// finally we are ready to send messages\nif err = o.Send(ctx, \u0026outboxer.OutboxMessage{\n    Payload: []byte(\"test payload\"),\n    Options: map[string]interface{}{\n        amqpOut.ExchangeNameOption: \"test\",\n        amqpOut.ExchangeTypeOption: \"topic\",\n        amqpOut.RoutingKeyOption:   \"test.send\",\n    },\n}); err != nil {\n    fmt.Printf(\"could not send message: %s\", err)\n    return\n}\n\n// we can also listen for errors and ok messages that were send\nfor {\n    select {\n    case err := \u003c-o.ErrChan():\n        fmt.Printf(\"could not send message: %s\", err)\n    case \u003c-o.OkChan():\n        fmt.Printf(\"message received\")\n        return\n    }\n}\n```\n\n## Features\n\nOutboxer comes with a few implementations of Data Stores and Event Streams.\n\n### Data Stores\n\n- [Postgres DataStore](storage/postgres/)\n- [MySQL DataStore](storage/mysql/)\n- [SQLServer DataStore](storage/sqlserver/)\n\n### Event Streams\n\n- [AMQP EventStream](es/amqp/)\n- [Kinesis EventStream](es/kinesis/)\n- [SQS EventStream](es/sqs/)\n- [GCP PubSub](es/pubsub/)\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests to us.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitalolelis%2Foutboxer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitalolelis%2Foutboxer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitalolelis%2Foutboxer/lists"}