Skip to content

Commit

Permalink
feat: we can produce with context now
Browse files Browse the repository at this point in the history
  • Loading branch information
w-h-a committed Jul 14, 2024
1 parent 063c657 commit 753352a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions streams/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type ProduceOptions struct {
Timestamp time.Time
Metadata map[string]string
Processed map[string]bool
Context context.Context
}

func ProduceWithTimestamp(t time.Time) ProduceOption {
Expand All @@ -108,11 +109,24 @@ func ProduceWithMetadata(md map[string]string) ProduceOption {
}
}

func ProduceWithProcessed(p map[string]bool) ProduceOption {
return func(o *ProduceOptions) {
o.Processed = p
}
}

func ProduceWithContext(ctx context.Context) ProduceOption {
return func(o *ProduceOptions) {
o.Context = ctx
}
}

func NewProduceOptions(opts ...ProduceOption) ProduceOptions {
options := ProduceOptions{
Timestamp: time.Now(),
Metadata: map[string]string{},
Processed: map[string]bool{},
Context: context.Background(),
}

for _, fn := range opts {
Expand Down

0 comments on commit 753352a

Please sign in to comment.