Back to godoc.org

Package boot

v0.3.1
Latest Go to latest

The latest major version is .

Published: Jul 12, 2019 | License: MIT | Module: github.com/dakalab/golib

Index

func DisableMock

func DisableMock()

DisableMock disables mocking, restore default functions

func EnableMock

func EnableMock() (*sql.DB, sqlmock.Sqlmock)

EnableMock enables mocking

func InitTracing

func InitTracing(cfg *config.TracingConfig) io.Closer

InitTracing initializes global tracer

func MockFailOpenDB

func MockFailOpenDB()

MockFailOpenDB mocks open db failure

func OpenDB

func OpenDB(config *config.DatabaseConfig) (*sql.DB, error)

OpenDB opens a DB connection

func OpenGRPC

func OpenGRPC(cfg *config.ClientConfig) *grpc.ClientConn

OpenGRPC opens gRPC connection

func SetGlobalDI

func SetGlobalDI(di DependencyInjecter)

SetGlobalDI sets the global DI

type Container

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

Container is the structure representing the dependency injecter

func DI

func DI() *Container

DI returns a new instance of Container

func (*Container) Bind

func (di *Container) Bind(k interface{}, v interface{}) DependencyInjecter

Bind binds a value to a key

func (*Container) Get

func (di *Container) Get(key interface{}) interface{}

Get gets the value bound to the key or nil if no value is present.

func (*Container) Unbind

func (di *Container) Unbind(k interface{}) DependencyInjecter

Unbind unbinds a value from a key

type DependencyInjecter

type DependencyInjecter interface {
	Bind(k interface{}, v interface{}) DependencyInjecter
	Unbind(k interface{}) DependencyInjecter
	Get(key interface{}) interface{}
}

DependencyInjecter is the interface of dependency injecter

func GlobalDI

func GlobalDI() DependencyInjecter

GlobalDI returns the global DI

func MustGetGlobalDI

func MustGetGlobalDI() DependencyInjecter

MustGetGlobalDI returns the global DI, panic when it is nil

type RedisClient

type RedisClient interface {
	redis.UniversalClient
}

RedisClient is the redis client wrapper

func OpenRedis

func OpenRedis(config *config.RedisConfig) RedisClient

OpenRedis connects to redis server and get a redis client.

Please note that IdleTimeout option should be smaller than timeout, refer: https://github.com/go-redis/redis/issues/84

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier