Documentation ¶
Index ¶
- Constants
- Variables
- func AsPubSubTestServerReactor(constructor any) fx.Option
- func AsPubSubTestServerReactors(constructors ...any) fx.Option
- func NewFxGcpPubSubClient(p FxGcpPubSubClientParam) (*pubsub.Client, error)
- func NewFxGcpPubSubSchemaClient(p FxGcpPubSubSchemaClientParam) (*pubsub.SchemaClient, error)
- func NewFxGcpPubSubTestServer(p FxGcpPubSubTestServerParam) *pstest.Server
- func PrepareSchema(params PrepareSchemaParams) fx.Option
- func PrepareTopic(params PrepareTopicParams) fx.Option
- func PrepareTopicAndSubscription(params PrepareTopicAndSubscriptionParams) fx.Option
- func PrepareTopicAndSubscriptionWithSchema(params PrepareTopicAndSubscriptionWithSchemaParams) fx.Option
- func PrepareTopicWithSchema(params PrepareTopicWithSchemaParams) fx.Option
- type DefaultPublisher
- type DefaultSubscriber
- type FxGcpPubSubClientParam
- type FxGcpPubSubPublisherParam
- type FxGcpPubSubSchemaClientParam
- type FxGcpPubSubSubscriberParam
- type FxGcpPubSubTestServerParam
- type PrepareSchemaParams
- type PrepareTopicAndSubscriptionParams
- type PrepareTopicAndSubscriptionWithSchemaParams
- type PrepareTopicParams
- type PrepareTopicWithSchemaParams
- type Publisher
- type Reactor
- type Subscriber
Constants ¶
const ModuleName = "gcppubsub"
ModuleName is the module name.
Variables ¶
var FxGcpPubSubModule = fx.Module( ModuleName, fx.Provide( NewFxGcpPubSubTestServer, NewFxGcpPubSubClient, NewFxGcpPubSubSchemaClient, fx.Annotate( ack.NewDefaultAckSupervisor, fx.As(new(ack.AckSupervisor)), ), fx.Annotate( codec.NewDefaultCodecFactory, fx.As(new(codec.CodecFactory)), ), fx.Annotate( schema.NewDefaultSchemaConfigRegistry, fx.As(new(schema.SchemaConfigRegistry)), ), fx.Annotate( topic.NewDefaultTopicFactory, fx.As(new(topic.TopicFactory)), ), fx.Annotate( topic.NewDefaultTopicRegistry, fx.As(new(topic.TopicRegistry)), ), fx.Annotate( subscription.NewDefaultSubscriptionFactory, fx.As(new(subscription.SubscriptionFactory)), ), fx.Annotate( subscription.NewDefaultSubscriptionRegistry, fx.As(new(subscription.SubscriptionRegistry)), ), fx.Annotate( reactor.NewDefaultWaiterSupervisor, fx.As(new(reactor.WaiterSupervisor)), ), fx.Annotate( NewFxGcpPubSubPublisher, fx.As(new(Publisher)), ), fx.Annotate( NewFxGcpPubSubSubscriber, fx.As(new(Subscriber)), ), ), AsPubSubTestServerReactor(ack.NewAckReactor), )
FxGcpPubSubModule is the Fx GCP pub/sub module.
Functions ¶
func AsPubSubTestServerReactor ¶ added in v1.2.0
AsPubSubTestServerReactor registers a Reactor into Fx.
func AsPubSubTestServerReactors ¶ added in v1.2.0
AsPubSubTestServerReactors registers a list of Reactor into Fx.
func NewFxGcpPubSubClient ¶
func NewFxGcpPubSubClient(p FxGcpPubSubClientParam) (*pubsub.Client, error)
NewFxGcpPubSubClient returns a pubsub.Client.
func NewFxGcpPubSubSchemaClient ¶ added in v1.2.0
func NewFxGcpPubSubSchemaClient(p FxGcpPubSubSchemaClientParam) (*pubsub.SchemaClient, error)
NewFxGcpPubSubSchemaClient returns a pubsub.SchemaClient.
func NewFxGcpPubSubTestServer ¶ added in v1.2.0
func NewFxGcpPubSubTestServer(p FxGcpPubSubTestServerParam) *pstest.Server
NewFxGcpPubSubTestServer returns a pstest.Server.
func PrepareSchema ¶ added in v1.2.0
func PrepareSchema(params PrepareSchemaParams) fx.Option
PrepareSchema prepares a pub/sub schema.
func PrepareTopic ¶ added in v1.2.0
func PrepareTopic(params PrepareTopicParams) fx.Option
PrepareTopic prepares a pub/sub topic.
func PrepareTopicAndSubscription ¶ added in v1.2.0
func PrepareTopicAndSubscription(params PrepareTopicAndSubscriptionParams) fx.Option
PrepareTopicAndSubscription prepares a pub/sub topic and an associated subscription.
func PrepareTopicAndSubscriptionWithSchema ¶ added in v1.2.0
func PrepareTopicAndSubscriptionWithSchema(params PrepareTopicAndSubscriptionWithSchemaParams) fx.Option
PrepareTopicAndSubscriptionWithSchema prepares a pub/sub topic and an associated subscription with a schema.
func PrepareTopicWithSchema ¶ added in v1.2.0
func PrepareTopicWithSchema(params PrepareTopicWithSchemaParams) fx.Option
PrepareTopicWithSchema prepares a pub/sub topic with a schema.
Types ¶
type DefaultPublisher ¶ added in v1.2.0
type DefaultPublisher struct {
// contains filtered or unexported fields
}
DefaultPublisher is the default Publisher implementation.
func NewDefaultPublisher ¶ added in v1.2.0
func NewDefaultPublisher(factory topic.TopicFactory, registry topic.TopicRegistry) *DefaultPublisher
NewDefaultPublisher returns a new DefaultPublisher instance.
func NewFxGcpPubSubPublisher ¶ added in v1.2.0
func NewFxGcpPubSubPublisher(p FxGcpPubSubPublisherParam) *DefaultPublisher
NewFxGcpPubSubPublisher returns a Publisher.
func (*DefaultPublisher) Publish ¶ added in v1.2.0
func (p *DefaultPublisher) Publish(ctx context.Context, topicID string, data any, options ...topic.PublishOption) (*pubsub.PublishResult, error)
Publish publishes data, with options, on a given topicID.
func (*DefaultPublisher) Stop ¶ added in v1.2.0
func (p *DefaultPublisher) Stop()
Stop stops gracefully all internal publishers.
type DefaultSubscriber ¶ added in v1.2.0
type DefaultSubscriber struct {
// contains filtered or unexported fields
}
DefaultSubscriber is the default Subscriber implementation.
func NewDefaultSubscriber ¶ added in v1.2.0
func NewDefaultSubscriber(factory subscription.SubscriptionFactory, registry subscription.SubscriptionRegistry) *DefaultSubscriber
NewDefaultSubscriber returns a new DefaultSubscriber instance.
func NewFxGcpPubSubSubscriber ¶ added in v1.2.0
func NewFxGcpPubSubSubscriber(p FxGcpPubSubSubscriberParam) *DefaultSubscriber
NewFxGcpPubSubSubscriber returns a Subscriber.
func (*DefaultSubscriber) Subscribe ¶ added in v1.2.0
func (s *DefaultSubscriber) Subscribe(ctx context.Context, subscriptionID string, f subscription.SubscribeFunc, options ...subscription.SubscribeOption) error
Subscribe handle received data using a subscription.SubscribeFunc, with options, from a given subscriptionID.
type FxGcpPubSubClientParam ¶
type FxGcpPubSubClientParam struct { fx.In LifeCycle fx.Lifecycle Context context.Context Config *config.Config Server *pstest.Server }
FxGcpPubSubClientParam allows injection of the required dependencies in NewFxGcpPubSubClient.
type FxGcpPubSubPublisherParam ¶ added in v1.2.0
type FxGcpPubSubPublisherParam struct { fx.In LifeCycle fx.Lifecycle Config *config.Config Factory topic.TopicFactory Registry topic.TopicRegistry }
FxGcpPubSubPublisherParam allows injection of the required dependencies in NewFxGcpPubSubPublisher.
type FxGcpPubSubSchemaClientParam ¶ added in v1.2.0
type FxGcpPubSubSchemaClientParam struct { fx.In LifeCycle fx.Lifecycle Context context.Context Config *config.Config Server *pstest.Server }
FxGcpPubSubSchemaClientParam allows injection of the required dependencies in NewFxGcpPubSubSchemaClient.
type FxGcpPubSubSubscriberParam ¶ added in v1.2.0
type FxGcpPubSubSubscriberParam struct { fx.In Factory subscription.SubscriptionFactory Registry subscription.SubscriptionRegistry }
FxGcpPubSubSubscriberParam allows injection of the required dependencies in NewFxGcpPubSubPublisher.
type FxGcpPubSubTestServerParam ¶ added in v1.2.0
type PrepareSchemaParams ¶ added in v1.2.0
type PrepareSchemaParams struct { SchemaID string SchemaConfig pubsub.SchemaConfig }
PrepareSchemaParams represents the parameters used in PrepareSchema.
type PrepareTopicAndSubscriptionParams ¶ added in v1.2.0
type PrepareTopicAndSubscriptionParams struct { TopicID string TopicConfig pubsub.TopicConfig SubscriptionID string SubscriptionConfig pubsub.SubscriptionConfig }
PrepareTopicAndSubscriptionParams represents the parameters used in PrepareTopicAndSubscription.
type PrepareTopicAndSubscriptionWithSchemaParams ¶ added in v1.2.0
type PrepareTopicAndSubscriptionWithSchemaParams struct { TopicID string TopicConfig pubsub.TopicConfig SubscriptionID string SubscriptionConfig pubsub.SubscriptionConfig SchemaID string SchemaConfig pubsub.SchemaConfig SchemaEncoding pubsub.SchemaEncoding }
PrepareTopicAndSubscriptionWithSchemaParams represents the parameters used in PrepareTopicAndSubscriptionWithSchema.
type PrepareTopicParams ¶ added in v1.2.0
type PrepareTopicParams struct { TopicID string TopicConfig pubsub.TopicConfig }
PrepareTopicParams represents the parameters used in PrepareTopic.
type PrepareTopicWithSchemaParams ¶ added in v1.2.0
type PrepareTopicWithSchemaParams struct { TopicID string TopicConfig pubsub.TopicConfig SchemaID string SchemaConfig pubsub.SchemaConfig SchemaEncoding pubsub.SchemaEncoding }
PrepareTopicWithSchemaParams represents the parameters used in PrepareTopicWithSchema.
type Publisher ¶ added in v1.2.0
type Publisher interface { Publish(ctx context.Context, topicID string, data any, options ...topic.PublishOption) (*pubsub.PublishResult, error) Stop() }
Publisher is the interface for high level publishers.
type Subscriber ¶ added in v1.2.0
type Subscriber interface {
Subscribe(ctx context.Context, subscriptionID string, f subscription.SubscribeFunc, options ...subscription.SubscribeOption) error
}
Subscriber is the interface for high level subscribers.