catch

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PreRequest   bool
	KafkaBrokers []string
	TimeoutSec   int
}

Config defines the configuration for Catch-Factory.

type Factory

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

Factory handles creating appropriate Kafka-Consumers and creating a result-channel for every request. Check Factory.Catch function.

func NewFactory

func NewFactory(ctx context.Context, config Config) (*Factory, error)

NewFactory returns a new Factory instance.

func (*Factory) Catch

func (f *Factory) Catch(
	group string,
	topic string,
	uuid uuuid.UUID,
) (<-chan *model.KafkaResponse, error)

Catch creates a new Kafka-Consumer if one does not exist for that specific ID. Otherwise an existing cached Consumer is returned. ID here refers to "Group+Topic" for the Consumer. This is not analogous to traditional Consumers that simply forward any Kafka Messages. This returns a new channel for every request. The request's response is then sent on that channel when the response arrives. It determines the correct response for request by using the response-UUID. If a response arrives before the request for it is registered, it caches the response until the request for it is received, and the response is sent out as soon request arrives.

Jump to

Keyboard shortcuts

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