Skip to content

Commit

Permalink
txn: add PollFetches and Produce to GroupTransactSession
Browse files Browse the repository at this point in the history
This may help discoverability of how to use a group transact session
properly: the flow should be poll, begin, produce, end.
  • Loading branch information
twmb committed Mar 29, 2021
1 parent c8cd120 commit 582335d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/kgo/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down

0 comments on commit 582335d

Please sign in to comment.