Documentation ¶
Overview ¶
Package debug contains
- chaincode methods names {service_name}Chaincode_{method_name}
- chaincode interface definition {service_name}Chaincode
- chaincode gateway definition {service_name}}Gateway
- chaincode service to cckit router registration func
Package debug is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func AddHandlers(r *router.Group, prefix string, middleware ...router.MiddlewareFunc)
- func DeleteStateByPrefixes(s state.State, prefixes []string) (map[string]uint32, error)
- func InvokeStateClean(c router.Context) (interface{}, error)
- func InvokeStateDelete(c router.Context) (interface{}, error)
- func InvokeStatePut(c router.Context) (interface{}, error)
- func QueryKeysList(c router.Context) (interface{}, error)
- func QueryStateGet(c router.Context) (interface{}, error)
- func RegisterDebugStateServiceChaincode(r *cckit_router.Group, cc DebugStateServiceChaincode) error
- func RegisterDebugStateServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterDebugStateServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DebugStateServiceClient) error
- func RegisterDebugStateServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterDebugStateServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DebugStateServiceServer) error
- func RegisterDebugStateServiceServer(s *grpc.Server, srv DebugStateServiceServer)
- func StateAsIs(ctx router.Context) state.State
- type CompositeKey
- func (*CompositeKey) Descriptor() ([]byte, []int)deprecated
- func (x *CompositeKey) GetKey() []string
- func (*CompositeKey) ProtoMessage()
- func (x *CompositeKey) ProtoReflect() protoreflect.Message
- func (x *CompositeKey) Reset()
- func (x *CompositeKey) String() string
- func (this *CompositeKey) Validate() error
- type CompositeKeys
- func (*CompositeKeys) Descriptor() ([]byte, []int)deprecated
- func (x *CompositeKeys) GetKeys() []*CompositeKey
- func (*CompositeKeys) ProtoMessage()
- func (x *CompositeKeys) ProtoReflect() protoreflect.Message
- func (x *CompositeKeys) Reset()
- func (x *CompositeKeys) String() string
- func (this *CompositeKeys) Validate() error
- type DebugStateServiceChaincode
- type DebugStateServiceClient
- type DebugStateServiceGateway
- func (c *DebugStateServiceGateway) DeleteState(ctx context.Context, in *CompositeKey) (*Value, error)
- func (c *DebugStateServiceGateway) DeleteStates(ctx context.Context, in *Prefixes) (*PrefixesMatchCount, error)
- func (c *DebugStateServiceGateway) GetState(ctx context.Context, in *CompositeKey) (*Value, error)
- func (c *DebugStateServiceGateway) Invoker() cckit_gateway.ChaincodeInstanceInvoker
- func (c *DebugStateServiceGateway) ListKeys(ctx context.Context, in *Prefix) (*CompositeKeys, error)
- func (c *DebugStateServiceGateway) PutState(ctx context.Context, in *Value) (*Value, error)
- func (c *DebugStateServiceGateway) ServiceDef() cckit_gateway.ServiceDef
- type DebugStateServiceServer
- type Prefix
- type Prefixes
- type PrefixesMatchCount
- func (*PrefixesMatchCount) Descriptor() ([]byte, []int)deprecated
- func (x *PrefixesMatchCount) GetMatches() map[string]uint32
- func (*PrefixesMatchCount) ProtoMessage()
- func (x *PrefixesMatchCount) ProtoReflect() protoreflect.Message
- func (x *PrefixesMatchCount) Reset()
- func (x *PrefixesMatchCount) String() string
- func (this *PrefixesMatchCount) Validate() error
- type StateFn
- type StateService
- func (s *StateService) DeleteState(ctx router.Context, key *CompositeKey) (*Value, error)
- func (s *StateService) DeleteStates(ctx router.Context, prefixes *Prefixes) (*PrefixesMatchCount, error)
- func (s *StateService) GetState(ctx router.Context, key *CompositeKey) (*Value, error)
- func (s *StateService) ListKeys(ctx router.Context, prefix *Prefix) (*CompositeKeys, error)
- func (s *StateService) PutState(ctx router.Context, val *Value) (*Value, error)
- type UnimplementedDebugStateServiceServer
- func (*UnimplementedDebugStateServiceServer) DeleteState(context.Context, *CompositeKey) (*Value, error)
- func (*UnimplementedDebugStateServiceServer) DeleteStates(context.Context, *Prefixes) (*PrefixesMatchCount, error)
- func (*UnimplementedDebugStateServiceServer) GetState(context.Context, *CompositeKey) (*Value, error)
- func (*UnimplementedDebugStateServiceServer) ListKeys(context.Context, *Prefix) (*CompositeKeys, error)
- func (*UnimplementedDebugStateServiceServer) PutState(context.Context, *Value) (*Value, error)
- type Value
- func (*Value) Descriptor() ([]byte, []int)deprecated
- func (x *Value) GetJson() string
- func (x *Value) GetKey() []string
- func (x *Value) GetValue() []byte
- func (*Value) ProtoMessage()
- func (x *Value) ProtoReflect() protoreflect.Message
- func (x *Value) Reset()
- func (x *Value) String() string
- func (this *Value) Validate() error
Constants ¶
const ( // DebugStateServiceChaincodeMethodPrefix allows to use multiple services with same method names in one chaincode DebugStateServiceChaincodeMethodPrefix = "DebugStateService." DebugStateServiceChaincode_ListKeys = DebugStateServiceChaincodeMethodPrefix + "ListKeys" DebugStateServiceChaincode_GetState = DebugStateServiceChaincodeMethodPrefix + "GetState" DebugStateServiceChaincode_PutState = DebugStateServiceChaincodeMethodPrefix + "PutState" DebugStateServiceChaincode_DeleteState = DebugStateServiceChaincodeMethodPrefix + "DeleteState" DebugStateServiceChaincode_DeleteStates = DebugStateServiceChaincodeMethodPrefix + "DeleteStates" )
DebugStateServiceChaincode method names
const ( InvokeStateCleanFunc = `StateClean` QueryStateKeysFunc = `StateKeys` QueryStateGetFunc = `StateGet` InvokeStatePutFunc = `StatePut` InvokeStateDeleteFunc = `StateDelete` )
Variables ¶
var ( // KeyParam parameter for get, put, delete data from state KeyParam = param.Strings(`key`) // PrefixParam parameter PrefixParam = param.String(`prefix`) // PrefixesParams parameter PrefixesParam = param.Strings(`prefixes`) // ValueParam parameter for putting value in state ValueParam = param.Bytes(`value`) )
var DebugStateServiceSwagger []byte
var File_debug_debug_state_proto protoreflect.FileDescriptor
Functions ¶
func AddHandlers ¶
func AddHandlers(r *router.Group, prefix string, middleware ...router.MiddlewareFunc)
AddHandler adds debug handlers to router, allows to add more middleware for example for access control
func DeleteStateByPrefixes ¶
DeleteStateByPrefixes deletes from state entries with matching key prefix raw function, do not use State wrappers, like encryption
func InvokeStateClean ¶
InvokeStateClean delete entries from state, prefix []string contains key prefixes or whole key
func InvokeStateDelete ¶
QueryStateGet router handler delete state entry by key ([]string)
func InvokeStatePut ¶
InvokeValueByKeyPut router handler puts value in chaincode state with composite key, created with key parts ([]string)
func QueryKeysList ¶
QueryKeysList router handler returns string slice with keys by prefix (object type)
func QueryStateGet ¶
QueryStateGet router handler returns state entry by key ([]string)
func RegisterDebugStateServiceChaincode ¶
func RegisterDebugStateServiceChaincode(r *cckit_router.Group, cc DebugStateServiceChaincode) error
RegisterDebugStateServiceChaincode registers service methods as chaincode router handlers
func RegisterDebugStateServiceHandler ¶
func RegisterDebugStateServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterDebugStateServiceHandler registers the http handlers for service DebugStateService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterDebugStateServiceHandlerClient ¶
func RegisterDebugStateServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DebugStateServiceClient) error
RegisterDebugStateServiceHandlerClient registers the http handlers for service DebugStateService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DebugStateServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DebugStateServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "DebugStateServiceClient" to call the correct interceptors.
func RegisterDebugStateServiceHandlerFromEndpoint ¶
func RegisterDebugStateServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterDebugStateServiceHandlerFromEndpoint is same as RegisterDebugStateServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterDebugStateServiceHandlerServer ¶
func RegisterDebugStateServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DebugStateServiceServer) error
RegisterDebugStateServiceHandlerServer registers the http handlers for service DebugStateService to "mux". UnaryRPC :call DebugStateServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDebugStateServiceHandlerFromEndpoint instead.
func RegisterDebugStateServiceServer ¶
func RegisterDebugStateServiceServer(s *grpc.Server, srv DebugStateServiceServer)
Types ¶
type CompositeKey ¶
type CompositeKey struct { Key []string `protobuf:"bytes,1,rep,name=key,proto3" json:"key,omitempty"` // contains filtered or unexported fields }
State key
func (*CompositeKey) Descriptor
deprecated
func (*CompositeKey) Descriptor() ([]byte, []int)
Deprecated: Use CompositeKey.ProtoReflect.Descriptor instead.
func (*CompositeKey) GetKey ¶
func (x *CompositeKey) GetKey() []string
func (*CompositeKey) ProtoMessage ¶
func (*CompositeKey) ProtoMessage()
func (*CompositeKey) ProtoReflect ¶
func (x *CompositeKey) ProtoReflect() protoreflect.Message
func (*CompositeKey) Reset ¶
func (x *CompositeKey) Reset()
func (*CompositeKey) String ¶
func (x *CompositeKey) String() string
func (*CompositeKey) Validate ¶
func (this *CompositeKey) Validate() error
type CompositeKeys ¶
type CompositeKeys struct { Keys []*CompositeKey `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` // contains filtered or unexported fields }
State keys
func (*CompositeKeys) Descriptor
deprecated
func (*CompositeKeys) Descriptor() ([]byte, []int)
Deprecated: Use CompositeKeys.ProtoReflect.Descriptor instead.
func (*CompositeKeys) GetKeys ¶
func (x *CompositeKeys) GetKeys() []*CompositeKey
func (*CompositeKeys) ProtoMessage ¶
func (*CompositeKeys) ProtoMessage()
func (*CompositeKeys) ProtoReflect ¶
func (x *CompositeKeys) ProtoReflect() protoreflect.Message
func (*CompositeKeys) Reset ¶
func (x *CompositeKeys) Reset()
func (*CompositeKeys) String ¶
func (x *CompositeKeys) String() string
func (*CompositeKeys) Validate ¶
func (this *CompositeKeys) Validate() error
type DebugStateServiceChaincode ¶
type DebugStateServiceChaincode interface { ListKeys(cckit_router.Context, *Prefix) (*CompositeKeys, error) GetState(cckit_router.Context, *CompositeKey) (*Value, error) PutState(cckit_router.Context, *Value) (*Value, error) DeleteState(cckit_router.Context, *CompositeKey) (*Value, error) DeleteStates(cckit_router.Context, *Prefixes) (*PrefixesMatchCount, error) }
DebugStateServiceChaincode chaincode methods interface
type DebugStateServiceClient ¶
type DebugStateServiceClient interface { // Get keys list, returns all keys or, if prefixes are defined, only prefix matched ListKeys(ctx context.Context, in *Prefix, opts ...grpc.CallOption) (*CompositeKeys, error) // Get state value by key GetState(ctx context.Context, in *CompositeKey, opts ...grpc.CallOption) (*Value, error) // Put state value PutState(ctx context.Context, in *Value, opts ...grpc.CallOption) (*Value, error) // Delete state value DeleteState(ctx context.Context, in *CompositeKey, opts ...grpc.CallOption) (*Value, error) // Delete all states or, if prefixes are defined, only prefix matched DeleteStates(ctx context.Context, in *Prefixes, opts ...grpc.CallOption) (*PrefixesMatchCount, error) }
DebugStateServiceClient is the client API for DebugStateService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewDebugStateServiceClient ¶
func NewDebugStateServiceClient(cc grpc.ClientConnInterface) DebugStateServiceClient
type DebugStateServiceGateway ¶
type DebugStateServiceGateway struct {
ChaincodeInstance cckit_gateway.ChaincodeInstance
}
gateway implementation gateway can be used as kind of SDK, GRPC or REST server ( via grpc-gateway or clay )
func NewDebugStateServiceGateway ¶
func NewDebugStateServiceGateway(sdk cckit_sdk.SDK, channel, chaincode string, opts ...cckit_gateway.Opt) *DebugStateServiceGateway
NewDebugStateServiceGateway creates gateway to access chaincode method via chaincode service
func NewDebugStateServiceGatewayFromInstance ¶
func NewDebugStateServiceGatewayFromInstance(chaincodeInstance cckit_gateway.ChaincodeInstance) *DebugStateServiceGateway
func (*DebugStateServiceGateway) DeleteState ¶
func (c *DebugStateServiceGateway) DeleteState(ctx context.Context, in *CompositeKey) (*Value, error)
func (*DebugStateServiceGateway) DeleteStates ¶
func (c *DebugStateServiceGateway) DeleteStates(ctx context.Context, in *Prefixes) (*PrefixesMatchCount, error)
func (*DebugStateServiceGateway) GetState ¶
func (c *DebugStateServiceGateway) GetState(ctx context.Context, in *CompositeKey) (*Value, error)
func (*DebugStateServiceGateway) Invoker ¶
func (c *DebugStateServiceGateway) Invoker() cckit_gateway.ChaincodeInstanceInvoker
func (*DebugStateServiceGateway) ListKeys ¶
func (c *DebugStateServiceGateway) ListKeys(ctx context.Context, in *Prefix) (*CompositeKeys, error)
func (*DebugStateServiceGateway) ServiceDef ¶
func (c *DebugStateServiceGateway) ServiceDef() cckit_gateway.ServiceDef
ServiceDef returns service definition
type DebugStateServiceServer ¶
type DebugStateServiceServer interface { // Get keys list, returns all keys or, if prefixes are defined, only prefix matched ListKeys(context.Context, *Prefix) (*CompositeKeys, error) // Get state value by key GetState(context.Context, *CompositeKey) (*Value, error) // Put state value PutState(context.Context, *Value) (*Value, error) // Delete state value DeleteState(context.Context, *CompositeKey) (*Value, error) // Delete all states or, if prefixes are defined, only prefix matched DeleteStates(context.Context, *Prefixes) (*PrefixesMatchCount, error) }
DebugStateServiceServer is the server API for DebugStateService service.
type Prefix ¶
type Prefix struct { // parts of key Key []string `protobuf:"bytes,1,rep,name=key,proto3" json:"key,omitempty"` // contains filtered or unexported fields }
State key prefix
func (*Prefix) Descriptor
deprecated
func (*Prefix) ProtoMessage ¶
func (*Prefix) ProtoMessage()
func (*Prefix) ProtoReflect ¶
func (x *Prefix) ProtoReflect() protoreflect.Message
type Prefixes ¶
type Prefixes struct { Prefixes []*Prefix `protobuf:"bytes,1,rep,name=prefixes,proto3" json:"prefixes,omitempty"` // contains filtered or unexported fields }
func (*Prefixes) Descriptor
deprecated
func (*Prefixes) GetPrefixes ¶
func (*Prefixes) ProtoMessage ¶
func (*Prefixes) ProtoMessage()
func (*Prefixes) ProtoReflect ¶
func (x *Prefixes) ProtoReflect() protoreflect.Message
type PrefixesMatchCount ¶
type PrefixesMatchCount struct { Matches map[string]uint32 `` /* 156-byte string literal not displayed */ // contains filtered or unexported fields }
State key prefix match count
func (*PrefixesMatchCount) Descriptor
deprecated
func (*PrefixesMatchCount) Descriptor() ([]byte, []int)
Deprecated: Use PrefixesMatchCount.ProtoReflect.Descriptor instead.
func (*PrefixesMatchCount) GetMatches ¶
func (x *PrefixesMatchCount) GetMatches() map[string]uint32
func (*PrefixesMatchCount) ProtoMessage ¶
func (*PrefixesMatchCount) ProtoMessage()
func (*PrefixesMatchCount) ProtoReflect ¶
func (x *PrefixesMatchCount) ProtoReflect() protoreflect.Message
func (*PrefixesMatchCount) Reset ¶
func (x *PrefixesMatchCount) Reset()
func (*PrefixesMatchCount) String ¶
func (x *PrefixesMatchCount) String() string
func (*PrefixesMatchCount) Validate ¶
func (this *PrefixesMatchCount) Validate() error
type StateService ¶
type StateService struct {
State StateFn
}
func NewStateService ¶
func NewStateService() *StateService
func (*StateService) DeleteState ¶
func (s *StateService) DeleteState(ctx router.Context, key *CompositeKey) (*Value, error)
func (*StateService) DeleteStates ¶
func (s *StateService) DeleteStates(ctx router.Context, prefixes *Prefixes) (*PrefixesMatchCount, error)
func (*StateService) GetState ¶
func (s *StateService) GetState(ctx router.Context, key *CompositeKey) (*Value, error)
func (*StateService) ListKeys ¶
func (s *StateService) ListKeys(ctx router.Context, prefix *Prefix) (*CompositeKeys, error)
type UnimplementedDebugStateServiceServer ¶
type UnimplementedDebugStateServiceServer struct { }
UnimplementedDebugStateServiceServer can be embedded to have forward compatible implementations.
func (*UnimplementedDebugStateServiceServer) DeleteState ¶
func (*UnimplementedDebugStateServiceServer) DeleteState(context.Context, *CompositeKey) (*Value, error)
func (*UnimplementedDebugStateServiceServer) DeleteStates ¶
func (*UnimplementedDebugStateServiceServer) DeleteStates(context.Context, *Prefixes) (*PrefixesMatchCount, error)
func (*UnimplementedDebugStateServiceServer) GetState ¶
func (*UnimplementedDebugStateServiceServer) GetState(context.Context, *CompositeKey) (*Value, error)
func (*UnimplementedDebugStateServiceServer) ListKeys ¶
func (*UnimplementedDebugStateServiceServer) ListKeys(context.Context, *Prefix) (*CompositeKeys, error)
type Value ¶
type Value struct { Key []string `protobuf:"bytes,1,rep,name=key,proto3" json:"key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` Json string `protobuf:"bytes,3,opt,name=json,proto3" json:"json,omitempty"` // contains filtered or unexported fields }
State value
func (*Value) Descriptor
deprecated
func (*Value) ProtoMessage ¶
func (*Value) ProtoMessage()
func (*Value) ProtoReflect ¶
func (x *Value) ProtoReflect() protoreflect.Message