Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface {
Register(services ...common.Service)
TopoSort() error
Services() []common.Service
Stats() ([]*entity.ApplicationStats, error)
// Migrate() error
InitService(ctx context.Context, name string) error
StartService(name string) error
StopService(name string, wait bool) error
RestartService(ctx context.Context, name string) error
}
type DB ¶
type DB interface {
ORM() *gorm.DB
DB() *sql.DB
FromContext(ctx context.Context) *gorm.DB
FromContextTimeout(ctx context.Context, timeout time.Duration) (*gorm.DB, context.CancelFunc)
Cleanup(schema bool) error
Reload() error
// Transaction executes fn within a database transaction.
Transaction(ctx context.Context, fn func(ctx context.Context) error, opts ...*sql.TxOptions) error
}
type Pubsub ¶
type Pubsub interface {
common.MessageSender
common.RawMessageSender
// Publish sends a message to all subscribers of the given topic.
// The publisher (from) will NOT receive its own message.
// If payload implements common.Message, MessageHandler subscribers are notified.
// RawMessageHandler subscribers are always notified.
Publish(from common.Named, topic string, kind string, payload any)
// Subscribe registers a service to receive events on the given topic.
// Topics are hierarchical: subscribing to "app" receives events from
// "app", "app/module", "app/module/component", etc.
Subscribe(svc common.Named, topic string)
// Unsubscribe removes a service's subscription from the given topic.
Unsubscribe(svc common.Named, topic string)
}
type PubsubDriver ¶
type PubsubDriver interface {
// Subscribe registers a named subscriber for the given topic and returns
// a channel that will receive messages published to matching topics.
Subscribe(name string, topic string) (<-chan entity.PubsubMessage, error)
// GetSubscribers returns the names of all subscribers matching the given topic,
// including those subscribed to parent topics.
GetSubscribers(topic string) []string
// Unsubscribe removes a subscriber from receiving events for the given topic.
// The subscriber's channel is closed.
Unsubscribe(name string, topic string) error
// Publish dispatches an event to local subscribers and handles
// cross-instance delivery (e.g., via Redis).
// The from parameter is the publisher's name, used to skip self-delivery.
Publish(from string, topic string, kind string, payload any) error
}
PubsubDriver defines the business interface for subscription storage and event delivery.
Click to show internal directories.
Click to hide internal directories.