Documentation ¶
Index ¶
Constants ¶
View Source
const StreamName = "service"
Variables ¶
View Source
var Module = fx.Options( fx.Provide( func(jt nats.JetStreamContext, conn *pgxpool.Pool) (Stream, error) { dc := stream.NewDependencyContainer() dc.AddSingleton(stream.DBDep, conn) return stream.NewNATSStream(jt, StreamName, dc, conn) }, ), fx.Invoke( func(conn *pgxpool.Pool) error { return repository.CreateTables(context.Background(), conn) }, func(lc fx.Lifecycle, stream Stream) error { lc.Append( fx.Hook{ OnStart: func(ctx context.Context) error { err := stream.CommandSubscriber("service", "start", command.ServiceStart) if err != nil { return fmt.Errorf("error subscribing to service.start: %w", err) } err = stream.CommandSubscriber("instance", "interview", command.InstanceInterview) if err != nil { return fmt.Errorf("error subscribing to instance.interview: %w", err) } err = stream.CommandSubscriber("instance", "sanity_check", command.InstanceSanityCheck) if err != nil { return fmt.Errorf("error subscribing to instance.sanity_check: %w", err) } err = stream.CommandSubscriber("instance", "stop", command.InstanceStop) if err != nil { return fmt.Errorf("error subscribing to instance.stop: %w", err) } err = stream.CommandSubscriber("service", "status", command.UpdateServiceStatus) if err != nil { return fmt.Errorf("error subscribing to service.status: %w", err) } return nil }, OnStop: func(ctx context.Context) error { err := stream.Unsubscribe() if err != nil { return fmt.Errorf("error unsubscribing: %w", err) } return nil }, }, ) return nil }, ), )
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.