summer

package module
v0.0.0-...-7dca3f0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Fork from github.com/facebookgo/inject By BUPTCZQ

Package startstop provides automatic Start/Stop for inject eliminating the necessity for manual ordering.

Index

Constants

This section is empty.

Variables

View Source
var UMARSHALTEXT_TYPE = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()

Functions

This section is empty.

Types

type Closer

type Closer interface {
	Close(ctx context.Context) error
}

Closer defines the Close method, objects satisfying this interface will be closed by Stop.

type Container

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

func (*Container) Get

func (c *Container) Get(name string) interface{}

func (*Container) GetMap

func (c *Container) GetMap() map[string]reflect.Type

func (*Container) GetType

func (c *Container) GetType(name string) reflect.Type

func (*Container) Register

func (c *Container) Register(proto interface{})

func (*Container) XMLConfigurationContainer

func (c *Container) XMLConfigurationContainer(data []byte, logger Logger) (*Graph, error)

func (*Container) XMLFileConfigurationContainer

func (c *Container) XMLFileConfigurationContainer(filename string, logger Logger) (*Graph, error)

type Dependence

type Dependence struct {
	Field  string
	Object *Dew
}

Dependence type

type Dew

type Dew struct {
	Value        interface{}
	Name         string            // Optional
	Complete     bool              // If true, the Value will be considered complete
	Options      map[string]Option // The field names that named dependency were injected into
	Dependencies []*Dependence     // Dew's Dependencies
	// contains filtered or unexported fields
}

An Dew in the Graph.

func (*Dew) String

func (o *Dew) String() string

String representation suitable for human consumption.

type Graph

type Graph struct {
	Logger Logger // Optional, will trigger debug logging.
	// contains filtered or unexported fields
}

The Graph of Objects.

func (*Graph) GetDewByName

func (g *Graph) GetDewByName(name string) *Dew

func (*Graph) Objects

func (g *Graph) Objects() []*Dew

Objects returns all known objects, named as well as unnamed. The returned elements are not in a stable order.

func (*Graph) Populate

func (g *Graph) Populate() error

Populate the incomplete Objects.

func (*Graph) Provide

func (g *Graph) Provide(objects ...*Dew) error

Provide objects to the Graph. The Dew documentation describes the impact of various fields.

func (*Graph) Run

func (g *Graph) Run()

func (*Graph) Start

func (g *Graph) Start(ctx context.Context) error

Start the graph, in the right order. Start will call Start or Open if an object satisfies the associated interface.

func (*Graph) Stop

func (g *Graph) Stop(ctx context.Context) error

Stop the graph, in the right order. Stop will call Stop or Close if an object satisfies the associated interface.

type Logger

type Logger interface {
	Debugf(f string, args ...interface{})
	Errorf(f string, args ...interface{})
}

Logger allows for simple logging as inject traverses and populates the object graph.

type Opener

type Opener interface {
	Open(ctx context.Context) error
}

Opener defines the Open method, objects satisfying this interface will be opened by Start.

type Option

type Option struct {
	Name  string
	Vapor []VaporOption
}

Field option

type Starter

type Starter interface {
	Start(ctx context.Context) error
}

Starter defines the Start method, objects satisfying this interface will be started by Start.

type Stopper

type Stopper interface {
	Stop(ctx context.Context) error
}

Stopper defines the Stop method, objects satisfying this interface will be stopped by Stop.

type VaporOption

type VaporOption struct {
	Name string
	Dew  string
}

Vapor option

Jump to

Keyboard shortcuts

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