-
Notifications
You must be signed in to change notification settings - Fork 897
RPC connector for TigerBeetle #3606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements an input connector for streaming [TigerBeetle](https://tigerbeetle.com/) events via CDC. The CDC process is stateless, so this connector requires a [`cache_resource`](https://docs.redpanda.com/redpanda-connect/components/caches/about) to persist progress and resume from the last acknowledged event when restarted. - Includes documentation and integration tests. - Licensing information in the file header is pending. For more information about TigerBeetle CDC, see https://docs.tigerbeetle.com/operating/cdc/
return service.NewConfigSpec(). | ||
Beta(). | ||
Categories("Services"). | ||
Version("0.0.1"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this version should be defined only once we know the release, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we're actually deprecating this method as we update the docs manually these days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same for Beta()
, when should we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you can get rid of that, but it's also harmless to leave in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Decide whether it will be included in the cloud
bundle.
return nil, nil, ctx.Err() | ||
} | ||
|
||
func newTigerbeetleInput(config *service.ParsedConfig, resources *service.Resources) (s service.BatchInput, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Decide whether to check the enterprise license.
func newTigerbeetleInput(config *service.ParsedConfig, resources *service.Resources) (s service.BatchInput, err error) { | |
func newTigerbeetleInput(config *service.ParsedConfig, resources *service.Resources) (s service.BatchInput, err error) { | |
if err := license.CheckRunningEnterprise(resources); err != nil { | |
return nil, err | |
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for setting this up. I believe we're happy to go ahead with a FOSS license so no need for license checks 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @batiati, this is great! I left a few very minor comments but only the assert one needs addressing. Extra thanks for adding the integration test ❤️
Thanks for the review @Jeffail! The Also, I replaced assertions that would Please let me know if I should add the license disclaimer to the source files. I didn't want to just copy from other files, as most say |
Also includes unit tests for all custom lint rules.
} | ||
|
||
// Extracts events from TigerBeetle. | ||
func (input *tigerbeetleInput) produce(ctx context.Context, client tb.Client, timestampLast uint64) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: how about using short variable name for self?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would usually be named just i
in Go!
I ended up using the TigerStyle coding style, favoring short but meaningful names and avoiding single-letter variables and abbreviations (except for trivial counters/indexes and well-known abbreviations like ctx
, config
, etc).
Although TigerStyle was originally designed for another programming language (Zig), I think we can apply most of the rules as long as they don't conflict with Go's idiomatic conventions. I don't want this code to feel alien 👽 compared with the rest of the code base!
It's your call, I'd be glad to follow your coding style otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at various inputs it feels like the "idiomatic" way in connect would be t
.
…ct/components/rate_limits/about) to throttle the number of requests made to TigerBeetle.
Hi @batiati Is this PR ready for another re-review? |
Yes, it is ready for review. I've addressed all comments so far. |
CI is failing due to The TigerBeetle client requires CGO to consume the static library But it seems there's a policy on builds that require external dependencies and CGO, like the ZeroMQ connector:
|
@batiati A couple more of minor comments but otherwise it's looking great! |
Thanks @josephwoodward! It's ready for another round. |
Could we add file headers to the Go files? |
Ideally we'd want to find a way of getting pure Go builds so that this isn't hidden away from the majority of users. Would it be possible to use something like https://github.com/ebitengine/purego here? |
I think we lack batch policy configuration |
@mmatczuk, initially I went with the batch policy, but some of the properties didn’t make sense for how TigerBeetle streams out CDC events (such as batching by size in bytes). Instead, we use the Perhaps the batch policy could still be useful for pipeline composability. Please let me know. |
Unfortunately, Go’s standard library does not expose a general-purpose FFI or dlopen-style interface! That’s how some of the other clients work. I know CGO can be a huge burden of complexity, but for the TigerBeetle client, adding a third-party dependency would not be worth the tradeoff either. |
@batiati would you be open to exploring an approach similar to opendal’s Go bindings without CGO. |
They also use https://github.com/apache/opendal/blob/a1b810910c6d288be8bd698521f843c622673c16/bindings/go/go.mod We are looking for alternatives in the meantime, but for the short term we can't get rid of CGO. |
Hi @Jeffail and @mmatczuk! I did some research to find alternatives, and we really can't remove the CGO dependency anytime soon. However, as we ship the client with pre-built static libraries for multiple targets, we don't depend too heavily on the system's libraries (as is the case with installing libzmq3-dev when the Please let me know what you suggest doing to teach the CI to build the TigerBeetle connector conditionally, and which pieces of documentation warnings we should include about it. |
Hey @batiati, we might try and enable CGO for some of our standard distributions of RPCN, but we almost definitely need to exclude this from our fips builds. In order to proceed I think we should guard all of these files with a CGO build constraint so that non-cgo builds aren't broken. If you could update your PR to do this then we can merge and handle the rest in a follow-up PR, where we'll probably create fips builds with a cherry-picked list of connectors. |
Implements an input connector for streaming TigerBeetle events via CDC.
The CDC process is stateless, so this connector requires a
cache_resource
to persist progress and resume from the last acknowledged event when restarted.For more information about TigerBeetle CDC, see https://docs.tigerbeetle.com/operating/cdc/