container

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package container includes the Container type, witch contains a collection of modules.

Index

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

type CommandProvider interface {
	ProvideCommand(command *cobra.Command)
}

CommandProvider provides cobra.Command.

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container holds all modules registered.

func (*Container) AddModule

func (c *Container) AddModule(module interface{})

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

func (c *Container) ApplyGRPCServer(server *grpc.Server)

ApplyGRPCServer iterates through every GRPCProvider registered in the container, and introduce a *grpc.Server to everyone.

func (*Container) ApplyRootCommand

func (c *Container) ApplyRootCommand(command *cobra.Command)

ApplyRootCommand iterates through every CommandProvider registered in the container, and introduce the root *cobra.Command to everyone.

func (*Container) ApplyRouter

func (c *Container) ApplyRouter(router *mux.Router)

ApplyRouter iterates through every HTTPProvider registered in the container, and introduce the router to everyone.

func (*Container) ApplyRunGroup

func (c *Container) ApplyRunGroup(g *run.Group)

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)
		}
	}
})

func (*Container) Shutdown

func (c *Container) Shutdown()

Shutdown iterates through every CloserProvider registered in the container, and calls them in parallel.

type CronProvider

type CronProvider interface {
	ProvideCron(crontab *cron.Cron)
}

CronProvider provides cron jobs.

type GRPCProvider added in v0.2.0

type GRPCProvider interface {
	ProvideGRPC(server *grpc.Server)
}

GRPCProvider provides gRPC services.

type HTTPProvider added in v0.2.0

type HTTPProvider interface {
	ProvideHTTP(router *mux.Router)
}

HTTPProvider provides http services.

type RunProvider

type RunProvider interface {
	ProvideRunGroup(group *run.Group)
}

RunProvider provides a runnable actor. Use it to register any server-like actions. For example, kafka consumer can be started here.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL