Documentation ¶
Overview ¶
Package container includes the Container type, witch contains a collection of modules.
Index ¶
- type CloserProvider
- type CommandProvider
- type Container
- func (c *Container) AddModule(module interface{})
- func (c *Container) ApplyCron(crontab *cron.Cron)
- func (c *Container) ApplyGRPCServer(server *grpc.Server)
- func (c *Container) ApplyRootCommand(command *cobra.Command)
- func (c *Container) ApplyRouter(router *mux.Router)
- func (c *Container) ApplyRunGroup(g *run.Group)
- func (c *Container) Modules() ifilter.Collection
- func (c *Container) Shutdown()
- type CronProvider
- type GRPCProvider
- type HTTPProvider
- type RunProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloserProvider ¶
type CloserProvider interface {
ProvideCloser()
}
CloserProvider provides a shutdown function that will be called when service exits.
type CommandProvider ¶
CommandProvider provides cobra.Command.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container holds all modules registered.
func (*Container) ApplyCron ¶
func (c *Container) ApplyCron(crontab *cron.Cron)
ApplyCron iterates through every CronProvider registered in the container, and introduce the *cron.Cron to everyone.
func (*Container) ApplyGRPCServer ¶
ApplyGRPCServer iterates through every GRPCProvider registered in the container, and introduce a *grpc.Server to everyone.
func (*Container) ApplyRootCommand ¶
ApplyRootCommand iterates through every CommandProvider registered in the container, and introduce the root *cobra.Command to everyone.
func (*Container) ApplyRouter ¶
ApplyRouter iterates through every HTTPProvider registered in the container, and introduce the router to everyone.
func (*Container) ApplyRunGroup ¶
ApplyRunGroup iterates through every RunProvider registered in the container, and introduce the *run.Group to everyone.
func (*Container) Modules ¶
func (c *Container) Modules() ifilter.Collection
Modules returns all modules in the container. This method is used to scan for custom interfaces. For example, The database module use Modules to scan for database migrations.
m.container.Modules().Filter(func(p MigrationProvider) { for _, migration := range p.ProvideMigration() { if migration.Connection == "" { migration.Connection = "default" } if migration.Connection == connection { migrations.Collection = append(migrations.Collection, migration) } } })
type CronProvider ¶
type CronProvider interface {
ProvideCron(crontab *cron.Cron)
}
CronProvider provides cron jobs.
type GRPCProvider ¶ added in v0.2.0
GRPCProvider provides gRPC services.
type HTTPProvider ¶ added in v0.2.0
HTTPProvider provides http services.
type RunProvider ¶
RunProvider provides a runnable actor. Use it to register any server-like actions. For example, kafka consumer can be started here.