Documentation ¶
Index ¶
- Constants
- Variables
- func MapEvents(eventMappings EventMappings) router.MiddlewareFunc
- func MapStates(stateMappings StateMappings) router.MiddlewareFunc
- func NewKeyRef(target interface{}, idx string, refKey, pKey state.Key) *schema.KeyRef
- func NewKeyRefId(target interface{}, idx string, refKey state.Key) *schema.KeyRefId
- type EventImpl
- type EventMapped
- type EventMapper
- type EventMappers
- type EventMapping
- type EventMappingOpt
- type EventMappings
- type InstanceKeyer
- type MappedState
- type Namer
- type ProtoEventMapped
- type ProtoStateMapped
- type StateImpl
- func (s *StateImpl) Delete(entry interface{}) (err error)
- func (s *StateImpl) Exists(entry interface{}) (exists bool, err error)
- func (s *StateImpl) Get(entry interface{}, target ...interface{}) (result interface{}, err error)
- func (s *StateImpl) GetByUniqKey(entry interface{}, idx string, idxVal []string) (result interface{}, err error)
- func (s *StateImpl) GetHistory(key interface{}, target interface{}) (result state.HistoryEntryList, err error)
- func (s *StateImpl) GetInt(key interface{}, defaultValue int) (result int, err error)
- func (s *StateImpl) Insert(entry interface{}, value ...interface{}) (err error)
- func (s *StateImpl) List(namespace interface{}, target ...interface{}) (result interface{}, err error)
- func (s *StateImpl) ListWith(entry interface{}, key state.Key) (result interface{}, err error)
- func (s *StateImpl) Logger() *shim.ChaincodeLogger
- func (s *StateImpl) MappingNamespace(schema interface{}) (state.Key, error)
- func (s *StateImpl) Put(entry interface{}, value ...interface{}) (err error)
- func (s *StateImpl) UseKeyTransformer(kt state.KeyTransformer) state.State
- func (s *StateImpl) UseStateGetTransformer(fb state.FromBytesTransformer) state.State
- func (s *StateImpl) UseStatePutTransformer(tb state.ToBytesTransformer) state.State
- type StateKeyDefinition
- type StateMapped
- type StateMapper
- type StateMappers
- type StateMapping
- type StateMappingOpt
- func List(list proto.Message) StateMappingOpt
- func PKeyAttr(attrs ...string) StateMappingOpt
- func PKeyComplexId(pkeySchema interface{}) StateMappingOpt
- func PKeyId() StateMappingOpt
- func PKeySchema(pkeySchema interface{}) StateMappingOpt
- func PKeyer(pkeyer InstanceKeyer) StateMappingOpt
- func StateNamespace(namespace state.Key) StateMappingOpt
- func UniqKey(name string, attrs ...[]string) StateMappingOpt
- type StateMappingOptions
- type StateMappings
- func (smm StateMappings) Add(schema interface{}, opts ...StateMappingOpt) StateMappings
- func (smm StateMappings) Exists(entry interface{}) bool
- func (smm StateMappings) Get(entry interface{}) (StateMapper, error)
- func (smm StateMappings) Map(entry interface{}) (mapped StateMapped, err error)
- func (smm StateMappings) PrimaryKey(entry interface{}) (pkey state.Key, err error)
Constants ¶
View Source
const KeyRefNamespace = `_idx`
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`) // ErrFieldTypeNotSupportedForKeyExtraction key cannot extracted from field ErrFieldTypeNotSupportedForKeyExtraction = errors.New(`field type not supported for key extraction`) ErrMappingUniqKeyExists = errors.New(`mapping uniq key exists`) ErrFieldNotExists = errors.New(`field is not exists`) ErrPrimaryKeyerNotDefined = errors.New(`primary keyer is not defined`) )
View Source
var KeyRefIdKeyer = attrsPKeyer([]string{`Schema`, `Idx`, `RefKey`})
View Source
var KeyRefIdMapper = &StateMapping{ schema: &schema.KeyRefId{}, namespace: state.Key{KeyRefNamespace}, primaryKeyer: KeyRefIdKeyer, }
View Source
var KeyRefMapper = &StateMapping{ schema: &schema.KeyRef{}, namespace: state.Key{KeyRefNamespace}, primaryKeyer: KeyRefIdKeyer, }
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) UseNameTransformer ¶
func (e *EventImpl) UseNameTransformer(nt state.StringTransformer) state.Event
func (*EventImpl) UseSetTransformer ¶
func (e *EventImpl) UseSetTransformer(tb state.ToBytesTransformer) state.Event
type EventMapped ¶ added in v0.4.3
type EventMapper ¶
type EventMappers ¶
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 EventMapped, err error)
type InstanceKeyer ¶
type MappedState ¶
type MappedState interface { state.State // ListWith allows to refine search criteria by adding to namespace key parts ListWith(schema interface{}, key state.Key) (result interface{}, err error) // GetByUniqKey return one entry GetByUniqKey(schema interface{}, idx string, idxVal []string) (result interface{}, err error) }
type ProtoEventMapped ¶ added in v0.4.3
type ProtoEventMapped struct {
// contains filtered or unexported fields
}
func NewProtoEventMapped ¶ added in v0.4.3
func NewProtoEventMapped(instance interface{}, eventMapper EventMapper) (*ProtoEventMapped, error)
func (*ProtoEventMapped) Name ¶ added in v0.4.3
func (em *ProtoEventMapped) Name() (string, error)
func (*ProtoEventMapped) ToBytes ¶ added in v0.4.3
func (em *ProtoEventMapped) ToBytes() ([]byte, error)
type ProtoStateMapped ¶ added in v0.4.3
type ProtoStateMapped struct {
// contains filtered or unexported fields
}
func NewKeyRefIdMapped ¶ added in v0.4.3
func NewKeyRefIdMapped(target interface{}, idx string, refKey state.Key) *ProtoStateMapped
func NewKeyRefMapped ¶ added in v0.4.3
func NewKeyRefMapped(target interface{}, idx string, refKey, pKey state.Key) *ProtoStateMapped
func NewProtoStateMapped ¶ added in v0.4.3
func NewProtoStateMapped(instance interface{}, stateMapper StateMapper) *ProtoStateMapped
func (*ProtoStateMapped) Keys ¶ added in v0.4.3
func (pm *ProtoStateMapped) Keys() ([]state.KeyValue, error)
func (*ProtoStateMapped) Mapper ¶ added in v0.4.3
func (pm *ProtoStateMapped) Mapper() StateMapper
func (*ProtoStateMapped) ToBytes ¶ added in v0.4.3
func (pm *ProtoStateMapped) ToBytes() ([]byte, error)
type StateImpl ¶
type StateImpl struct {
// contains filtered or unexported fields
}
func (*StateImpl) GetByUniqKey ¶ added in v0.4.3
func (*StateImpl) GetHistory ¶
func (s *StateImpl) GetHistory(key interface{}, target interface{}) (result state.HistoryEntryList, err error)
func (*StateImpl) Logger ¶
func (s *StateImpl) Logger() *shim.ChaincodeLogger
func (*StateImpl) MappingNamespace ¶
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 StateKeyDefinition ¶ added in v0.4.3
type StateMapped ¶ added in v0.4.3
type StateMapper ¶
type StateMapper interface { Schema() interface{} List() interface{} Namespace() state.Key PrimaryKey(instance interface{}) (key state.Key, err error) Keys(instance interface{}) (key []state.KeyValue, err error) }
StateMapper
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) PrimaryKey(schema interface{}) (key state.Key, err error) }
StateMappers interface for mappers collection
type StateMapping ¶
type StateMapping struct {
// contains filtered or unexported fields
}
StateMapping defines metadata for mapping from schema to state keys/values
func (*StateMapping) Keys ¶ added in v0.4.3
func (sm *StateMapping) Keys(entity interface{}) (kv []state.KeyValue, err error)
func (*StateMapping) List ¶ added in v0.4.2
func (sm *StateMapping) List() interface{}
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 List ¶ added in v0.4.2
func List(list proto.Message) StateMappingOpt
List defined list container, it must have `Items` attr
func PKeyAttr ¶
func PKeyAttr(attrs ...string) StateMappingOpt
func PKeyComplexId ¶ added in v0.4.2
func PKeyComplexId(pkeySchema interface{}) StateMappingOpt
func PKeyId ¶
func PKeyId() StateMappingOpt
func PKeySchema ¶
func PKeySchema(pkeySchema interface{}) StateMappingOpt
PKeySchema registers all fields from pkeySchema as part of primary key also register keyer for pkeySchema with with namespace from current schema
func PKeyer ¶
func PKeyer(pkeyer InstanceKeyer) StateMappingOpt
func StateNamespace ¶
func StateNamespace(namespace state.Key) StateMappingOpt
StateNamespace sets namespace for mapping
func UniqKey ¶ added in v0.4.3
func UniqKey(name string, attrs ...[]string) 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 StateMapped, err error)
func (StateMappings) PrimaryKey ¶ added in v0.4.3
func (smm StateMappings) PrimaryKey(entry interface{}) (pkey state.Key, err error)
Click to show internal directories.
Click to hide internal directories.