Documentation
¶
Index ¶
- Variables
- func NewEvent(eventSource string, eventType string, data json.RawMessage) (event.Event, error)
- type AmqpConfig
- type CloudEventProvider
- type CloudEventProviderClient
- func (c *CloudEventProviderClient) Alive() bool
- func (c *CloudEventProviderClient) Close() error
- func (c *CloudEventProviderClient) Pub(event event.Event) error
- func (c *CloudEventProviderClient) PubCtx(ctx context.Context, event event.Event) error
- func (c *CloudEventProviderClient) Reply(...) error
- func (c *CloudEventProviderClient) ReplyCtx(ctx context.Context, ...) error
- func (c *CloudEventProviderClient) Request(event event.Event, timeOut time.Duration) (*event.Event, error)
- func (c *CloudEventProviderClient) RequestCtx(ctx context.Context, event event.Event) (*event.Event, error)
- func (c *CloudEventProviderClient) Sub(fn func(event event.Event)) error
- func (c *CloudEventProviderClient) SubCtx(ctx context.Context, fn func(event event.Event)) error
- type Config
- type ConnectionType
- type HttpConfig
- type KafkaConfig
- type MqttConfig
- type NatsConfig
- type NatsJetstreamConfig
- type ProtocolType
Constants ¶
This section is empty.
Variables ¶
var ErrConfigKeyMissing = errors.New("required configKey is not set")
var ErrInvalidConfig = errors.New("invalid config (type of Config.Settings does not match Config.Protocol)")
Functions ¶
Types ¶
type AmqpConfig ¶
type AmqpConfig struct {
Url string `mapstructure:"url" envconfig:"URL" default:"127.0.0.1"`
}
type CloudEventProvider ¶
type CloudEventProvider interface {
Close() error
Alive() bool
Pub(event event.Event) error
PubCtx(ctx context.Context, event event.Event) error
Sub(fn func(event event.Event)) error
SubCtx(ctx context.Context, fn func(event event.Event)) error
Request(event event.Event, timeOut time.Duration) (*event.Event, error)
RequestCtx(ctx context.Context, event event.Event) (*event.Event, error)
Reply(responseFunc func(ctx context.Context, event event.Event) (*event.Event, error)) error
ReplyCtx(ctx context.Context, responseFunc func(ctx context.Context, event event.Event) (*event.Event, error)) error
}
type CloudEventProviderClient ¶
type CloudEventProviderClient struct {
// contains filtered or unexported fields
}
func New ¶
func New(conf Config, conType ConnectionType, topic string) (*CloudEventProviderClient, error)
New initializes a CloudEventProviderClient using the passed Config. In contrast to NewClient, it does not rely on a configuration other than the one provided.
func NewClient ¶
func NewClient(connectionType ConnectionType, topic string) (*CloudEventProviderClient, error)
NewClient initializes a CloudEventProviderClient. It uses viper.Viper as the config library and might make assumptions about your config.yaml
func (*CloudEventProviderClient) Alive ¶
func (c *CloudEventProviderClient) Alive() bool
func (*CloudEventProviderClient) Close ¶
func (c *CloudEventProviderClient) Close() error
func (*CloudEventProviderClient) Pub ¶
func (c *CloudEventProviderClient) Pub(event event.Event) error
Pub publishes the given event.Event DEPRECATED: Use PubCtx
func (*CloudEventProviderClient) Reply ¶
func (c *CloudEventProviderClient) Reply(responseFunc func(ctx context.Context, event event.Event) (*event.Event, error)) error
Reply method is blocking. Use it in a goroutine DEPRECATED: Use ReplyCtx
func (*CloudEventProviderClient) ReplyCtx ¶
func (c *CloudEventProviderClient) ReplyCtx(ctx context.Context, responseFunc func(ctx context.Context, event event.Event) (*event.Event, error)) error
ReplyCtx method is blocking. Use it in a goroutine
func (*CloudEventProviderClient) Request ¶
func (c *CloudEventProviderClient) Request(event event.Event, timeOut time.Duration) (*event.Event, error)
Request sends the given event.Event as a request and returns the response DEPRECATED: Use RequestCtx
func (*CloudEventProviderClient) RequestCtx ¶
func (c *CloudEventProviderClient) RequestCtx(ctx context.Context, event event.Event) (*event.Event, error)
RequestCtx sends the given event.Event as a request and returns the response
type Config ¶
type Config struct {
Protocol ProtocolType `mapstructure:"protocol"`
Settings protocolConfig
}
type ConnectionType ¶
type ConnectionType string
const ( ConnectionTypePub ConnectionType = "pub" ConnectionTypeSub ConnectionType = "sub" ConnectionTypeReq ConnectionType = "req" ConnectionTypeRep ConnectionType = "rep" )
const ( Pub ConnectionType = "pub" Sub ConnectionType = "sub" Req ConnectionType = "req" Rep ConnectionType = "rep" )
Deprecated, use ConnectionType*
type HttpConfig ¶
type KafkaConfig ¶
type MqttConfig ¶
type NatsConfig ¶
type NatsJetstreamConfig ¶
type NatsJetstreamConfig struct {
Url string `mapstructure:"url" envconfig:"URL" default:"127.0.0.1"`
QueueGroup string `mapstructure:"queueGroup,omitempty" envconfig:"QUEUE_GROUP"`
StreamType string `mapstructure:"streamType" envconfig:"STREAM_TYPE"`
TimeoutInSec time.Duration `mapstructure:"timeoutInSec,omitempty" envconfig:"REQUEST_TIMEOUT"`
}
type ProtocolType ¶
type ProtocolType string
const ( ProtocolTypeHttp ProtocolType = "http" ProtocolTypeKafka ProtocolType = "kafka" ProtocolTypeNats ProtocolType = "nats" ProtocolTypeNatsJetstream ProtocolType = "natsJetstream" ProtocolTypeMqtt ProtocolType = "mqtt" ProtocolTypeAmqp ProtocolType = "amqp" )
const ( Http ProtocolType = "http" Kafka ProtocolType = "kafka" Nats ProtocolType = "nats" NatsJetstream ProtocolType = "natsJetstream" Mqtt ProtocolType = "mqtt" Amqp ProtocolType = "amqp" )
Deprecated, use ProtocolType*