pool

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCEClientOpts = []ceclient.Option{
		ceclient.WithUUIDs(),
		ceclient.WithTimeNow(),
		ceclient.WithTracePropagation(),
	}

	DefaultHTTPOpts = []cehttp.Option{
		cehttp.WithRoundTripper(&ochttp.Transport{Propagation: &tracecontext.HTTPFormat{}}),
	}

	// ProviderSet provides the fanout and retry sync pools using the default client options. In
	// order to inject either pool, ProjectID, []Option, and config.ReadOnlyTargets must be
	// externally provided.
	ProviderSet = wire.NewSet(
		NewFanoutPool,
		NewRetryPool,
		cehttp.New,
		NewDeliverClient,
		NewPubsubClient,
		NewRetryClient,
		wire.Value(DefaultHTTPOpts),
		wire.Value(DefaultCEClientOpts),
	)
)

Functions

func NewPubsubClient added in v0.15.0

func NewPubsubClient(ctx context.Context, projectID ProjectID) (*pubsub.Client, error)

NewPubsubClient provides a pubsub client for the supplied project ID.

Types

type DeliverClient added in v0.15.0

type DeliverClient ceclient.Client

func NewDeliverClient added in v0.15.0

func NewDeliverClient(hp *cehttp.Protocol, opts ...ceclient.Option) (DeliverClient, error)

NewDeliverClient provides a delivery CE client from an HTTP protocol and a list of CE client options.

type FanoutPool added in v0.15.0

type FanoutPool struct {
	// contains filtered or unexported fields
}

FanoutPool is the sync pool for fanout handlers. For each broker in the config, it will attempt to create a handler. It will also stop/delete the handler if the corresponding broker is deleted in the config.

func InitializeTestFanoutPool added in v0.15.0

func InitializeTestFanoutPool(ctx context.Context, targets config.ReadonlyTargets, pubsubClient *pubsub.Client, opts ...Option) (*FanoutPool, error)

func NewFanoutPool added in v0.15.0

func NewFanoutPool(
	targets config.ReadonlyTargets,
	pubsubClient *pubsub.Client,
	deliverClient DeliverClient,
	retryClient RetryClient,
	opts ...Option,
) (*FanoutPool, error)

NewFanoutPool creates a new fanout handler pool.

func (*FanoutPool) SyncOnce added in v0.15.0

func (p *FanoutPool) SyncOnce(ctx context.Context) error

SyncOnce syncs once the handler pool based on the targets config.

type Option

type Option func(*Options)

Option is for providing individual option.

func WithDeliveryTimeout added in v0.15.0

func WithDeliveryTimeout(t time.Duration) Option

WithDeliveryTimeout sets the DeliveryTimeout.

func WithHandlerConcurrency

func WithHandlerConcurrency(c int) Option

WithHandlerConcurrency sets HandlerConcurrency.

func WithMaxConcurrentPerEvent

func WithMaxConcurrentPerEvent(c int) Option

WithMaxConcurrentPerEvent sets MaxConcurrencyPerEvent.

func WithPubsubReceiveSettings

func WithPubsubReceiveSettings(s pubsub.ReceiveSettings) Option

WithPubsubReceiveSettings sets PubsubReceiveSettings.

func WithTimeoutPerEvent

func WithTimeoutPerEvent(t time.Duration) Option

WithTimeoutPerEvent sets TimeoutPerEvent.

type Options

type Options struct {
	// HandlerConcurrency is the number of goroutines
	// will be spawned in each handler.
	HandlerConcurrency int
	// MaxConcurrencyPerEvent is the max number of goroutines
	// will be spawned to handle an event.
	MaxConcurrencyPerEvent int
	// TimeoutPerEvent is the timeout for handling an event.
	TimeoutPerEvent time.Duration
	// DeliveryTimeout is the timeout for delivering an event to a consumer.
	DeliveryTimeout time.Duration
	// PubsubReceiveSettings is the pubsub receive settings.
	PubsubReceiveSettings pubsub.ReceiveSettings
}

Options holds all the options for create handler pool.

func NewOptions

func NewOptions(opts ...Option) (*Options, error)

NewOptions creates a Options.

type ProjectID added in v0.15.0

type ProjectID string

type RetryClient added in v0.15.0

type RetryClient ceclient.Client

func NewRetryClient added in v0.15.0

func NewRetryClient(ctx context.Context, client *pubsub.Client, opts ...ceclient.Option) (RetryClient, error)

NewRetryClient provides a retry CE client from a PubSub client and list of CE client options.

type RetryPool added in v0.15.0

type RetryPool struct {
	// contains filtered or unexported fields
}

RetryPool is the sync pool for retry handlers. For each trigger in the config, it will attempt to create a handler. It will also stop/delete the handler if the corresponding trigger is deleted in the config.

func InitializeTestRetryPool added in v0.15.0

func InitializeTestRetryPool(targets config.ReadonlyTargets, pubsubClient *pubsub.Client, opts ...Option) (*RetryPool, error)

func NewRetryPool added in v0.15.0

func NewRetryPool(targets config.ReadonlyTargets, pubsubClient *pubsub.Client, deliverClient DeliverClient, opts ...Option) (*RetryPool, error)

NewRetryPool creates a new retry handler pool.

func (*RetryPool) SyncOnce added in v0.15.0

func (p *RetryPool) SyncOnce(ctx context.Context) error

SyncOnce syncs once the handler pool based on the targets config.

type SyncPool added in v0.15.0

type SyncPool interface {
	SyncOnce(ctx context.Context) error
}

func StartSyncPool added in v0.15.0

func StartSyncPool(ctx context.Context, syncPool SyncPool, syncSignal <-chan struct{}) (SyncPool, error)

StartSyncPool starts the sync pool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL