mirror of
https://github.com/harness/drone.git
synced 2025-05-05 14:12:36 +08:00

This change is adding the following: - Add ConsumerOption and HandlerOption for configuring stream consumers and handlers. - Add Readeroption and HandlerOption for configuring event readers and handlers - Add HandlerOption and ReaderOption support to all existing event reader implementations
29 lines
984 B
Go
29 lines
984 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package events
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/harness/gitness/stream"
|
|
)
|
|
|
|
// StreamProducer is an abstraction of a producer from the streams package.
|
|
type StreamProducer interface {
|
|
Send(ctx context.Context, streamID string, payload map[string]interface{}) (string, error)
|
|
}
|
|
|
|
// StreamConsumer is an abstraction of a consumer from the streams package.
|
|
type StreamConsumer interface {
|
|
Register(streamID string, handler stream.HandlerFunc, opts ...stream.HandlerOption) error
|
|
Configure(opts ...stream.ConsumerOption)
|
|
Start(ctx context.Context) error
|
|
Errors() <-chan error
|
|
Infos() <-chan string
|
|
}
|
|
|
|
// StreamConsumerFactoryFunc is an abstraction of a factory method for stream consumers.
|
|
type StreamConsumerFactoryFunc func(groupName string, consumerName string) (StreamConsumer, error)
|