mockup

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EagerInjectors = map[string]interface{}{
	"mockup_explorerserver": InjectMockupExplorerServer,
	"mockup_restapiserver":  InjectMockupRESTAPIServer,
}
View Source
var Injectors = map[string]interface{}{
	"mockup_database":   InjectMockupDB,
	"mockup_blockchain": InjectMockupBlockchain,
}

Dependency Injection List

Injectors stores module_name(key) with injector_func(value) using map. For wiring, name of implement using in config with injector function.

Examples :

var Injectors = map[string]interface{}{
	"mockup_database":   InjectMockupDB,
	"mockup_blockchain": InjectMockupBlockchain,
}

var EagerInjectors = map[string]interface{}{
	"mockup_explorerserver": InjectMockupExplorerServer,
	"mockup_restapiserver":  InjectMockupRESTAPIServer,
}

Functions

This section is empty.

Types

type Block

type Block interface {
	GetData() string
}

type Blockchain

type Blockchain interface {
	// Init inits blockchain.
	Init() error
	// AddBlock adds data to blockchain.
	AddBlock(data string) error
	// GetBlocks gets all the blocks.
	GetBlocks() []Block
	// Close closes blockchain.
	Close() error
}

func InjectMockupBlockchain

func InjectMockupBlockchain(db Database) (Blockchain, error)

InjectMockupBlockchain injects dependencies and inits of Blockchain.

func NewMockupBlockchain

func NewMockupBlockchain(db Database) Blockchain

type Database

type Database interface {
	// Connect DB.
	Connect() error
	// Close closes the REST API Server.
	Close() error
}

func InjectMockupDB

func InjectMockupDB(config viperjacket.Config) (Database, error)

InjectMockupDB injects dependencies and inits of Database.

func NewMockupDB

func NewMockupDB(config viperjacket.Config) Database

type ExplorerServer

type ExplorerServer interface {
	// Serve serves server.
	Serve() error
	// GetAllBlockData return all blocks of blockchain.
	GetAllBlockData() []string
	// Close closes blockchain.
	Close() error
}

func InjectMockupExplorerServer

func InjectMockupExplorerServer(config viperjacket.Config, blockchain Blockchain) (ExplorerServer, error)

InjectMockupExplorerServer injects dependencies and inits of ExplorerServer.

func NewMockupExplorerServer

func NewMockupExplorerServer(config viperjacket.Config, blockchain Blockchain) ExplorerServer

type MockupBlock

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

func (*MockupBlock) GetData

func (mb *MockupBlock) GetData() string

type MockupBlockchain

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

func (*MockupBlockchain) AddBlock

func (mbc *MockupBlockchain) AddBlock(data string) error

func (*MockupBlockchain) Close

func (mbc *MockupBlockchain) Close() error

func (*MockupBlockchain) GetBlocks

func (mbc *MockupBlockchain) GetBlocks() []Block

func (*MockupBlockchain) Init

func (mbc *MockupBlockchain) Init() error

type MockupDB

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

func (*MockupDB) Close

func (mdb *MockupDB) Close() error

func (*MockupDB) Connect

func (mdb *MockupDB) Connect() error

type MockupExplorerServer

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

func (*MockupExplorerServer) Close

func (mes *MockupExplorerServer) Close() error

func (*MockupExplorerServer) GetAllBlockData

func (mes *MockupExplorerServer) GetAllBlockData() []string

func (*MockupExplorerServer) Serve

func (mes *MockupExplorerServer) Serve() error

type MockupRESTAPIServer

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

func (*MockupRESTAPIServer) Close

func (mrs *MockupRESTAPIServer) Close() error

func (*MockupRESTAPIServer) GetPaths

func (mrs *MockupRESTAPIServer) GetPaths() []string

func (*MockupRESTAPIServer) Serve

func (mrs *MockupRESTAPIServer) Serve() error

type RESTAPIServer

type RESTAPIServer interface {
	// Serve serves server.
	Serve() error
	// GetPaths gets all the paths of REST API.
	GetPaths() []string
	// Close closes blockchain.
	Close() error
}

func InjectMockupInvalidReturnTest

func InjectMockupInvalidReturnTest(config viperjacket.Config, blockchain Blockchain) (RESTAPIServer, func(), error)

InjectMockupInvalidReturnTest injects dependencies and inits of RESTAPIServer and return invalid format.

func InjectMockupRESTAPIServer

func InjectMockupRESTAPIServer(config viperjacket.Config, blockchain Blockchain) (RESTAPIServer, error)

InjectMockupRESTAPIServer injects dependencies and inits of RESTAPIServer.

func NewMockupRESTAPIServer

func NewMockupRESTAPIServer(config viperjacket.Config, blockchain Blockchain) RESTAPIServer

type TestImplement added in v1.1.1

type TestImplement struct{}

func (*TestImplement) Close added in v1.1.1

func (ti *TestImplement) Close() error

func (*TestImplement) Test added in v1.1.1

func (ti *TestImplement) Test() error

type TestInterface added in v1.1.1

type TestInterface interface {
	Test() error
	Close() error
}

func InjectMockupInvalidImplTest added in v1.1.1

func InjectMockupInvalidImplTest() (TestInterface, error)

InjectMockupInvalidImplTest injects test dependency for test.

func NewTestImplement added in v1.1.1

func NewTestImplement() TestInterface

Jump to

Keyboard shortcuts

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