framework

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: MIT Imports: 3 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	// Bind bind a service provider
	Bind(provider ServiceProvider, isSingleton bool) error
	// Singlton is Bind a singlton service provider
	Singleton(provider ServiceProvider) error
	// IsBind check a service provider has been bind
	IsBind(key string) bool

	// Make to get a service provider
	Make(key string) (interface{}, error)
	// MustMake to get a service provider which will not return error
	// if error,panic it
	// If you use it, make sure it will not panic, or you can cover it
	MustMake(key string) interface{}
	// MakeNew to new a service
	// The service Must not be singlton, it with params to make a new service
	MakeNew(key string, params []interface{}) (interface{}, error)
}

Container is a core struct which store provider and instance

type HadeContainer

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

HadeContainer is instance of Container

func NewHadeContainer

func NewHadeContainer() *HadeContainer

NewHadeContainer is new instance

func (*HadeContainer) Bind

func (hade *HadeContainer) Bind(provider ServiceProvider, isSingleton bool) error

Bind make relationship between provider and contract

func (*HadeContainer) GetProviders

func (hade *HadeContainer) GetProviders() []ServiceProvider

func (*HadeContainer) IsBind

func (hade *HadeContainer) IsBind(key string) bool

func (*HadeContainer) Make

func (hade *HadeContainer) Make(key string) (interface{}, error)

func (*HadeContainer) MakeNew

func (hade *HadeContainer) MakeNew(key string, params []interface{}) (interface{}, error)

func (*HadeContainer) MustMake

func (hade *HadeContainer) MustMake(key string) interface{}

func (*HadeContainer) PrintList

func (hade *HadeContainer) PrintList() []string

func (*HadeContainer) Singleton

func (hade *HadeContainer) Singleton(provider ServiceProvider) error

Singleton make provider be Singleton, instance once

type NewInstance

type NewInstance func(...interface{}) (interface{}, error)

NewInstance define a instantiate function for making a new service

type ServiceProvider

type ServiceProvider interface {
	// Register registe a new function for make a service instance
	Register(Container) NewInstance
	// Boot will called when the service instantiate
	Boot(Container) error
	// IsDefer define whether the service instantiate when first make or register
	IsDefer() bool
	// Params define the necessary params for NewInstance
	Params() []interface{}
	/// Name define the name for this service
	Name() string
}

ServiceProvider define a service provider should implement

Directories

Path Synopsis
doc
gin
Package gin implements a HTTP web framework called gin.
Package gin implements a HTTP web framework called gin.
middleware
provider
app
env
id
log
ssh

Jump to

Keyboard shortcuts

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