pinger

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

README

Pinger - hyperledger fabric chaincode ping extension

Often there is a need to find out if everything is correct with chaincode. To do it we would like to ping CC and know some information.

CCKit provides pinger extension for implementing ping opportunity in Hyperledger Fabric chaincodes. When chaincode will be pinged, you get information about invoker, his certificate and time.

Pinger implemented in two version:

  1. As chaincode handlers
  2. As service, that can be embedded in chaincode, using chaincode-as-service mode

Documentation

Overview

Package pinger 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 pinger is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Package pinger contains structure and functions for checking chain code accessibility

Index

Constants

View Source
const (

	// ChaincodePingerServiceChaincodeMethodPrefix allows to use multiple services with same method names in one chaincode
	ChaincodePingerServiceChaincodeMethodPrefix = "ChaincodePingerService."

	ChaincodePingerServiceChaincode_Ping = ChaincodePingerServiceChaincodeMethodPrefix + "Ping"
)

ChaincodePingerServiceChaincode method names

View Source
const (
	// PingKeyPrefix prefix for PingInfo composite key in chain code state
	PingKeyPrefix = `PING`
	// PingEvent event name
	PingEvent = `PING`
	// FuncPingConstant func name
	FuncPingConstant = `pingLocal`
	// FuncPing func name
	FuncPing = `ping`
	// FuncPings func name
	FuncPings = `pings`
)

Variables

View Source
var ChaincodePingerServiceSwagger []byte
View Source
var File_pinger_chaincode_pinger_proto protoreflect.FileDescriptor

Functions

func Ping

func Ping(ctx r.Context) (interface{}, error)

Ping create PingInfo struct with tx creator ID and certificate in PEM format

func RegisterChaincodePingerServiceChaincode

func RegisterChaincodePingerServiceChaincode(r *cckit_router.Group, cc ChaincodePingerServiceChaincode) error

RegisterChaincodePingerServiceChaincode registers service methods as chaincode router handlers

func RegisterChaincodePingerServiceHandler

func RegisterChaincodePingerServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterChaincodePingerServiceHandler registers the http handlers for service ChaincodePingerService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterChaincodePingerServiceHandlerClient

func RegisterChaincodePingerServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChaincodePingerServiceClient) error

RegisterChaincodePingerServiceHandlerClient registers the http handlers for service ChaincodePingerService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChaincodePingerServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChaincodePingerServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ChaincodePingerServiceClient" to call the correct interceptors.

func RegisterChaincodePingerServiceHandlerFromEndpoint

func RegisterChaincodePingerServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterChaincodePingerServiceHandlerFromEndpoint is same as RegisterChaincodePingerServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterChaincodePingerServiceHandlerServer

func RegisterChaincodePingerServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChaincodePingerServiceServer) error

RegisterChaincodePingerServiceHandlerServer registers the http handlers for service ChaincodePingerService to "mux". UnaryRPC :call ChaincodePingerServiceServer 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 RegisterChaincodePingerServiceHandlerFromEndpoint instead.

func RegisterChaincodePingerServiceServer

func RegisterChaincodePingerServiceServer(s *grpc.Server, srv ChaincodePingerServiceServer)

Types

type ChaincodePinger

type ChaincodePinger struct{}

func NewService

func NewService() *ChaincodePinger

func (*ChaincodePinger) Ping

func (c *ChaincodePinger) Ping(ctx router.Context, _ *empty.Empty) (*PingInfo, error)

type ChaincodePingerServiceChaincode

type ChaincodePingerServiceChaincode interface {
	Ping(cckit_router.Context, *emptypb.Empty) (*PingInfo, error)
}

ChaincodePingerServiceChaincode chaincode methods interface

type ChaincodePingerServiceClient

type ChaincodePingerServiceClient interface {
	// ping chaincode
	Ping(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PingInfo, error)
}

ChaincodePingerServiceClient is the client API for ChaincodePingerService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type ChaincodePingerServiceGateway

type ChaincodePingerServiceGateway 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 NewChaincodePingerServiceGateway

func NewChaincodePingerServiceGateway(sdk cckit_sdk.SDK, channel, chaincode string, opts ...cckit_gateway.Opt) *ChaincodePingerServiceGateway

NewChaincodePingerServiceGateway creates gateway to access chaincode method via chaincode service

func NewChaincodePingerServiceGatewayFromInstance

func NewChaincodePingerServiceGatewayFromInstance(chaincodeInstance cckit_gateway.ChaincodeInstance) *ChaincodePingerServiceGateway

func (*ChaincodePingerServiceGateway) Invoker

func (*ChaincodePingerServiceGateway) Ping

func (*ChaincodePingerServiceGateway) ServiceDef

ServiceDef returns service definition

type ChaincodePingerServiceServer

type ChaincodePingerServiceServer interface {
	// ping chaincode
	Ping(context.Context, *emptypb.Empty) (*PingInfo, error)
}

ChaincodePingerServiceServer is the server API for ChaincodePingerService service.

type PingInfo

type PingInfo struct {
	InvokerId           string                 `protobuf:"bytes,1,opt,name=invoker_id,json=invokerId,proto3" json:"invoker_id,omitempty"`
	InvokerCert         []byte                 `protobuf:"bytes,2,opt,name=invoker_cert,json=invokerCert,proto3" json:"invoker_cert,omitempty"`
	EndorsingServerTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=endorsing_server_time,json=endorsingServerTime,proto3" json:"endorsing_server_time,omitempty"`
	TxTime              *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=tx_time,json=txTime,proto3" json:"tx_time,omitempty"`
	// contains filtered or unexported fields
}

stores time and certificate of ping tx creator

func (*PingInfo) Descriptor deprecated

func (*PingInfo) Descriptor() ([]byte, []int)

Deprecated: Use PingInfo.ProtoReflect.Descriptor instead.

func (*PingInfo) GetEndorsingServerTime

func (x *PingInfo) GetEndorsingServerTime() *timestamppb.Timestamp

func (*PingInfo) GetInvokerCert

func (x *PingInfo) GetInvokerCert() []byte

func (*PingInfo) GetInvokerId

func (x *PingInfo) GetInvokerId() string

func (*PingInfo) GetTxTime

func (x *PingInfo) GetTxTime() *timestamppb.Timestamp

func (*PingInfo) ProtoMessage

func (*PingInfo) ProtoMessage()

func (*PingInfo) ProtoReflect

func (x *PingInfo) ProtoReflect() protoreflect.Message

func (*PingInfo) Reset

func (x *PingInfo) Reset()

func (*PingInfo) String

func (x *PingInfo) String() string

func (*PingInfo) Validate

func (this *PingInfo) Validate() error

type UnimplementedChaincodePingerServiceServer

type UnimplementedChaincodePingerServiceServer struct {
}

UnimplementedChaincodePingerServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedChaincodePingerServiceServer) Ping

Jump to

Keyboard shortcuts

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