From 582335d61310224354b5ba815b82ed9bd22751f0 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Sat, 20 Mar 2021 15:43:56 -0600 Subject: [PATCH] txn: add PollFetches and Produce to GroupTransactSession This may help discoverability of how to use a group transact session properly: the flow should be poll, begin, produce, end. --- pkg/kgo/txn.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/kgo/txn.go b/pkg/kgo/txn.go index 91025b7a..10a48808 100644 --- a/pkg/kgo/txn.go +++ b/pkg/kgo/txn.go @@ -92,6 +92,22 @@ func (cl *Client) AssignGroupTransactSession(group string, opts ...GroupOpt) *Gr return s } +// PollFetches is a wrapper around Client.PollFetches, with the exact same +// semantics. Please refer to that function's documentation. +// +// It is invalid to call PollFetches concurrently with Begin or End. +func (s *GroupTransactSession) PollFetches(ctx context.Context) Fetches { + return s.cl.PollFetches(ctx) +} + +// Produce is a wrapper around Client.Produce, with the exact same semantics. +// Please refer to that function's documentation. +// +// It is invalid to call Produce concurrently with Begin or End. +func (s *GroupTransactSession) Produce(ctx context.Context, r *Record, promise func(*Record, error)) error { + return s.cl.Produce(ctx, r, promise) +} + // Begin begins a transaction, returning an error if the client has no // transactional id or is already in a transaction. //