mapping

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEntryTypeNotSupported entry type has no appropriate mapper type
	ErrEntryTypeNotSupported = errors.New(`entry type not supported for mapping`)

	// ErrEntryTypeNotDefined
	ErrStateMappingNotFound = errors.New(`state mapping not found`)

	// ErrEventMappingNotFound
	ErrEventMappingNotFound = errors.New(`event mapping not found`)
)
View Source
var (
	ErrFieldNotExists         = errors.New(`field is not exists`)
	ErrPrimaryKeyerNotDefined = errors.New(`primary keyer is not defined`)
)

Functions

func MapEvents

func MapEvents(eventMappings EventMappings) router.MiddlewareFunc

func MapStates

func MapStates(stateMappings StateMappings) router.MiddlewareFunc

Types

type EventImpl

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

func NewEvent

func NewEvent(stub shim.ChaincodeStubInterface, mappings EventMappings) *EventImpl

func (*EventImpl) Set

func (e *EventImpl) Set(entry interface{}, value ...interface{}) error

func (*EventImpl) UseNameTransformer

func (e *EventImpl) UseNameTransformer(nt state.StringTransformer) state.Event

func (*EventImpl) UseSetTransformer

func (e *EventImpl) UseSetTransformer(tb state.ToBytesTransformer) state.Event

type EventMapper

type EventMapper interface {
	Schema() interface{}
	Name(instance interface{}) (string, error)
}

type EventMappers

type EventMappers interface {
	Exists(schema interface{}) (exists bool)
	Map(schema interface{}) (keyValue state.KeyValue, err error)
	Get(schema interface{}) (eventMapper EventMapper, err error)
}

type EventMapping

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

func (EventMapping) Name

func (em EventMapping) Name(instance interface{}) (string, error)

func (EventMapping) Schema

func (em EventMapping) Schema() interface{}

type EventMappingOpt

type EventMappingOpt func(*EventMapping)

type EventMappings

type EventMappings map[string]*EventMapping

func (EventMappings) Add

func (emm EventMappings) Add(schema interface{}, opts ...EventMappingOpt) EventMappings

func (EventMappings) Exists

func (emm EventMappings) Exists(entry interface{}) bool

func (EventMappings) Get

func (emm EventMappings) Get(entry interface{}) (EventMapper, error)

func (EventMappings) Map

func (emm EventMappings) Map(entry interface{}) (mapped state.NameValue, err error)

type InstanceKeyer

type InstanceKeyer func(instance interface{}) (key state.Key, err error)

type MappedState

type MappedState interface {
	state.State
	// MappingNamespace returns mapping for schema
	MappingNamespace(schema interface{}) (state.Key, error)
	// ListWith extends schema namespace with key
	ListWith(schema interface{}, key state.Key) (result []interface{}, err error)
}

type Namer

type Namer func(entity interface{}) string

type ProtoEventMapper

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

func NewProtoEventMapper

func NewProtoEventMapper(instance interface{}, eventMapper EventMapper) (*ProtoEventMapper, error)

func (*ProtoEventMapper) Name

func (em *ProtoEventMapper) Name() (string, error)

func (*ProtoEventMapper) ToBytes

func (em *ProtoEventMapper) ToBytes() ([]byte, error)

type ProtoStateMapper

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

func NewProtoStateMapper

func NewProtoStateMapper(instance interface{}, stateMapper StateMapper) (*ProtoStateMapper, error)

func (*ProtoStateMapper) Key

func (pm *ProtoStateMapper) Key() (state.Key, error)

func (*ProtoStateMapper) ToBytes

func (pm *ProtoStateMapper) ToBytes() ([]byte, error)

type StateImpl

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

func WrapState

func WrapState(s state.State, mappings StateMappings) *StateImpl

func (*StateImpl) Delete

func (s *StateImpl) Delete(entry interface{}) (err error)

func (*StateImpl) Exists

func (s *StateImpl) Exists(entry interface{}) (exists bool, err error)

func (*StateImpl) Get

func (s *StateImpl) Get(entry interface{}, target ...interface{}) (result interface{}, err error)

func (*StateImpl) GetHistory

func (s *StateImpl) GetHistory(key interface{}, target interface{}) (result state.HistoryEntryList, err error)

func (*StateImpl) GetInt

func (s *StateImpl) GetInt(key interface{}, defaultValue int) (result int, err error)

func (*StateImpl) Insert

func (s *StateImpl) Insert(entry interface{}, value ...interface{}) (err error)

func (*StateImpl) List

func (s *StateImpl) List(namespace interface{}, target ...interface{}) (result []interface{}, err error)

func (*StateImpl) ListWith

func (s *StateImpl) ListWith(schema interface{}, key state.Key) (result []interface{}, err error)

func (*StateImpl) Logger

func (s *StateImpl) Logger() *shim.ChaincodeLogger

func (*StateImpl) MappingNamespace

func (s *StateImpl) MappingNamespace(schema interface{}) (state.Key, error)

func (*StateImpl) Put

func (s *StateImpl) Put(entry interface{}, value ...interface{}) (err error)

func (*StateImpl) UseKeyTransformer

func (s *StateImpl) UseKeyTransformer(kt state.KeyTransformer) state.State

func (*StateImpl) UseStateGetTransformer

func (s *StateImpl) UseStateGetTransformer(fb state.FromBytesTransformer) state.State

func (*StateImpl) UseStatePutTransformer

func (s *StateImpl) UseStatePutTransformer(tb state.ToBytesTransformer) state.State

type StateMapper

type StateMapper interface {
	Schema() interface{}
	Namespace() state.Key
	PrimaryKey(instance interface{}) (key state.Key, err error)
}

type StateMappers

type StateMappers interface {
	Exists(schema interface{}) (exists bool)
	Map(schema interface{}) (keyValue state.KeyValue, err error)
	Get(schema interface{}) (stateMapper StateMapper, err error)
}

StateMappers interface for mappers collection

type StateMapping

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

func (*StateMapping) Namespace

func (sm *StateMapping) Namespace() state.Key

func (*StateMapping) PrimaryKey

func (sm *StateMapping) PrimaryKey(entity interface{}) (state.Key, error)

func (*StateMapping) Schema

func (sm *StateMapping) Schema() interface{}

type StateMappingOpt

type StateMappingOpt func(*StateMapping, StateMappings)

func PKeyAttr

func PKeyAttr(attrs ...string) StateMappingOpt

func PKeyId

func PKeyId() StateMappingOpt

func PKeySchema

func PKeySchema(pkeySchema interface{}) StateMappingOpt

func PKeyer

func PKeyer(pkeyer InstanceKeyer) StateMappingOpt

func StateNamespace

func StateNamespace(namespace state.Key) StateMappingOpt

type StateMappingOptions

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

type StateMappings

type StateMappings map[string]*StateMapping

func (StateMappings) Add

func (smm StateMappings) Add(schema interface{}, opts ...StateMappingOpt) StateMappings

func (StateMappings) Exists

func (smm StateMappings) Exists(entry interface{}) bool

func (StateMappings) Get

func (smm StateMappings) Get(entry interface{}) (StateMapper, error)

func (StateMappings) Map

func (smm StateMappings) Map(entry interface{}) (mapped state.KeyValue, err error)

Jump to

Keyboard shortcuts

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