grpc

package
v2.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ServerName = "grpc"

	BlockHeightHeader = "x-cosmos-block-height"
)

Variables

View Source
var (
	ErrInvalidLengthService        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowService          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group")
)
View Source
var FlagAddress = prefix("address")
View Source
var Service_serviceDesc = _Service_serviceDesc

Functions

func RegisterServiceServer

func RegisterServiceServer(s grpc1.Server, srv ServiceServer)

Types

type CfgOption

type CfgOption func(*Config)

CfgOption is a function that allows to overwrite the default server configuration.

func Disable

func Disable() CfgOption

Disable the grpc-gateway server by default (default enabled).

func OverwriteDefaultConfig

func OverwriteDefaultConfig(newCfg *Config) CfgOption

OverwriteDefaultConfig overwrites the default config with the new config.

type Config

type Config struct {
	// Enable defines if the gRPC server should be enabled.
	Enable bool `mapstructure:"enable" toml:"enable" comment:"Enable defines if the gRPC server should be enabled."`

	// Address defines the API server to listen on
	Address string `mapstructure:"address" toml:"address" comment:"Address defines the gRPC server address to bind to."`

	// MaxRecvMsgSize defines the max message size in bytes the server can receive.
	// The default value is 10MB.
	MaxRecvMsgSize int `` /* 172-byte string literal not displayed */

	// MaxSendMsgSize defines the max message size in bytes the server can send.
	// The default value is math.MaxInt32.
	MaxSendMsgSize int `` /* 178-byte string literal not displayed */
}

Config defines configuration for the gRPC server.

func DefaultConfig

func DefaultConfig() *Config

type Handler

type Handler struct {
	RequestName  string `protobuf:"bytes,1,opt,name=request_name,json=requestName,proto3" json:"request_name,omitempty"`
	ResponseName string `protobuf:"bytes,2,opt,name=response_name,json=responseName,proto3" json:"response_name,omitempty"`
}

Handler defines a query handler

func (*Handler) Descriptor

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

func (*Handler) GetRequestName

func (m *Handler) GetRequestName() string

func (*Handler) GetResponseName

func (m *Handler) GetResponseName() string

func (*Handler) Marshal

func (m *Handler) Marshal() (dAtA []byte, err error)

func (*Handler) MarshalTo

func (m *Handler) MarshalTo(dAtA []byte) (int, error)

func (*Handler) MarshalToSizedBuffer

func (m *Handler) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Handler) ProtoMessage

func (*Handler) ProtoMessage()

func (*Handler) Reset

func (m *Handler) Reset()

func (*Handler) Size

func (m *Handler) Size() (n int)

func (*Handler) String

func (m *Handler) String() string

func (*Handler) Unmarshal

func (m *Handler) Unmarshal(dAtA []byte) error

func (*Handler) XXX_DiscardUnknown

func (m *Handler) XXX_DiscardUnknown()

func (*Handler) XXX_Marshal

func (m *Handler) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Handler) XXX_Merge

func (m *Handler) XXX_Merge(src proto.Message)

func (*Handler) XXX_Size

func (m *Handler) XXX_Size() int

func (*Handler) XXX_Unmarshal

func (m *Handler) XXX_Unmarshal(b []byte) error

type ListQueryHandlersRequest

type ListQueryHandlersRequest struct {
}

ListQueryHandlersRequest is the request for the ListQueryHandlers method

func (*ListQueryHandlersRequest) Descriptor

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

func (*ListQueryHandlersRequest) Marshal

func (m *ListQueryHandlersRequest) Marshal() (dAtA []byte, err error)

func (*ListQueryHandlersRequest) MarshalTo

func (m *ListQueryHandlersRequest) MarshalTo(dAtA []byte) (int, error)

func (*ListQueryHandlersRequest) MarshalToSizedBuffer

func (m *ListQueryHandlersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ListQueryHandlersRequest) ProtoMessage

func (*ListQueryHandlersRequest) ProtoMessage()

func (*ListQueryHandlersRequest) Reset

func (m *ListQueryHandlersRequest) Reset()

func (*ListQueryHandlersRequest) Size

func (m *ListQueryHandlersRequest) Size() (n int)

func (*ListQueryHandlersRequest) String

func (m *ListQueryHandlersRequest) String() string

func (*ListQueryHandlersRequest) Unmarshal

func (m *ListQueryHandlersRequest) Unmarshal(dAtA []byte) error

func (*ListQueryHandlersRequest) XXX_DiscardUnknown

func (m *ListQueryHandlersRequest) XXX_DiscardUnknown()

func (*ListQueryHandlersRequest) XXX_Marshal

func (m *ListQueryHandlersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ListQueryHandlersRequest) XXX_Merge

func (m *ListQueryHandlersRequest) XXX_Merge(src proto.Message)

func (*ListQueryHandlersRequest) XXX_Size

func (m *ListQueryHandlersRequest) XXX_Size() int

func (*ListQueryHandlersRequest) XXX_Unmarshal

func (m *ListQueryHandlersRequest) XXX_Unmarshal(b []byte) error

type ListQueryHandlersResponse

type ListQueryHandlersResponse struct {
	Handlers []*Handler `protobuf:"bytes,1,rep,name=handlers,proto3" json:"handlers,omitempty"`
}

ListQueryHandlersResponse is the response for the ListQueryHandlers method

func (*ListQueryHandlersResponse) Descriptor

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

func (*ListQueryHandlersResponse) GetHandlers

func (m *ListQueryHandlersResponse) GetHandlers() []*Handler

func (*ListQueryHandlersResponse) Marshal

func (m *ListQueryHandlersResponse) Marshal() (dAtA []byte, err error)

func (*ListQueryHandlersResponse) MarshalTo

func (m *ListQueryHandlersResponse) MarshalTo(dAtA []byte) (int, error)

func (*ListQueryHandlersResponse) MarshalToSizedBuffer

func (m *ListQueryHandlersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ListQueryHandlersResponse) ProtoMessage

func (*ListQueryHandlersResponse) ProtoMessage()

func (*ListQueryHandlersResponse) Reset

func (m *ListQueryHandlersResponse) Reset()

func (*ListQueryHandlersResponse) Size

func (m *ListQueryHandlersResponse) Size() (n int)

func (*ListQueryHandlersResponse) String

func (m *ListQueryHandlersResponse) String() string

func (*ListQueryHandlersResponse) Unmarshal

func (m *ListQueryHandlersResponse) Unmarshal(dAtA []byte) error

func (*ListQueryHandlersResponse) XXX_DiscardUnknown

func (m *ListQueryHandlersResponse) XXX_DiscardUnknown()

func (*ListQueryHandlersResponse) XXX_Marshal

func (m *ListQueryHandlersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ListQueryHandlersResponse) XXX_Merge

func (m *ListQueryHandlersResponse) XXX_Merge(src proto.Message)

func (*ListQueryHandlersResponse) XXX_Size

func (m *ListQueryHandlersResponse) XXX_Size() int

func (*ListQueryHandlersResponse) XXX_Unmarshal

func (m *ListQueryHandlersResponse) XXX_Unmarshal(b []byte) error

type OptionFunc

type OptionFunc[T transaction.Tx] func(*Server[T])

func WithCfgOptions

func WithCfgOptions[T transaction.Tx](cfgOptions ...CfgOption) OptionFunc[T]

WithCfgOptions allows to overwrite the default server configuration.

func WithExtraGRPCHandlers

func WithExtraGRPCHandlers[T transaction.Tx](handlers ...func(*grpc.Server) error) OptionFunc[T]

WithExtraGRPCHandlers allows to register extra handlers on the grpc server.

type QueryRequest

type QueryRequest struct {
	Request *any.Any `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"`
}

QueryRequest is the request for the Query method

func (*QueryRequest) Descriptor

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

func (*QueryRequest) GetRequest

func (m *QueryRequest) GetRequest() *any.Any

func (*QueryRequest) Marshal

func (m *QueryRequest) Marshal() (dAtA []byte, err error)

func (*QueryRequest) MarshalTo

func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryRequest) MarshalToSizedBuffer

func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryRequest) ProtoMessage

func (*QueryRequest) ProtoMessage()

func (*QueryRequest) Reset

func (m *QueryRequest) Reset()

func (*QueryRequest) Size

func (m *QueryRequest) Size() (n int)

func (*QueryRequest) String

func (m *QueryRequest) String() string

func (*QueryRequest) Unmarshal

func (m *QueryRequest) Unmarshal(dAtA []byte) error

func (*QueryRequest) XXX_DiscardUnknown

func (m *QueryRequest) XXX_DiscardUnknown()

func (*QueryRequest) XXX_Marshal

func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryRequest) XXX_Merge

func (m *QueryRequest) XXX_Merge(src proto.Message)

func (*QueryRequest) XXX_Size

func (m *QueryRequest) XXX_Size() int

func (*QueryRequest) XXX_Unmarshal

func (m *QueryRequest) XXX_Unmarshal(b []byte) error

type QueryResponse

type QueryResponse struct {
	Response *any.Any `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"`
}

QueryResponse is the response for the Query method

func (*QueryResponse) Descriptor

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

func (*QueryResponse) GetResponse

func (m *QueryResponse) GetResponse() *any.Any

func (*QueryResponse) Marshal

func (m *QueryResponse) Marshal() (dAtA []byte, err error)

func (*QueryResponse) MarshalTo

func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryResponse) MarshalToSizedBuffer

func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryResponse) ProtoMessage

func (*QueryResponse) ProtoMessage()

func (*QueryResponse) Reset

func (m *QueryResponse) Reset()

func (*QueryResponse) Size

func (m *QueryResponse) Size() (n int)

func (*QueryResponse) String

func (m *QueryResponse) String() string

func (*QueryResponse) Unmarshal

func (m *QueryResponse) Unmarshal(dAtA []byte) error

func (*QueryResponse) XXX_DiscardUnknown

func (m *QueryResponse) XXX_DiscardUnknown()

func (*QueryResponse) XXX_Marshal

func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryResponse) XXX_Merge

func (m *QueryResponse) XXX_Merge(src proto.Message)

func (*QueryResponse) XXX_Size

func (m *QueryResponse) XXX_Size() int

func (*QueryResponse) XXX_Unmarshal

func (m *QueryResponse) XXX_Unmarshal(b []byte) error

type Server

type Server[T transaction.Tx] struct {
	// contains filtered or unexported fields
}

func New

func New[T transaction.Tx](
	logger log.Logger,
	interfaceRegistry server.InterfaceRegistry,
	queryHandlers map[string]appmodulev2.Handler,
	queryable func(ctx context.Context, version uint64, msg transaction.Msg) (transaction.Msg, error),
	cfg server.ConfigMap,
	opts ...OptionFunc[T],
) (*Server[T], error)

New creates a new grpc server.

func NewWithConfigOptions

func NewWithConfigOptions[T transaction.Tx](opts ...CfgOption) *Server[T]

NewWithConfigOptions creates a new GRPC server with the provided config options. It is *not* a fully functional server (since it has been created without dependencies) The returned server should only be used to get and set configuration.

func (*Server[T]) Config

func (s *Server[T]) Config() any

func (*Server[T]) Name

func (s *Server[T]) Name() string

func (*Server[T]) Start

func (s *Server[T]) Start(ctx context.Context) error

func (*Server[T]) StartCmdFlags

func (s *Server[T]) StartCmdFlags() *pflag.FlagSet

func (*Server[T]) Stop

func (s *Server[T]) Stop(ctx context.Context) error

type ServiceClient

type ServiceClient interface {
	// Query queries the server with a request, the request can be any sdk Msg.
	Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)
	// ListQueryHandlers lists all the available query handlers.
	ListQueryHandlers(ctx context.Context, in *ListQueryHandlersRequest, opts ...grpc.CallOption) (*ListQueryHandlersResponse, error)
}

ServiceClient is the client API for Service service.

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

func NewServiceClient

func NewServiceClient(cc grpc1.ClientConn) ServiceClient

type ServiceServer

type ServiceServer interface {
	// Query queries the server with a request, the request can be any sdk Msg.
	Query(context.Context, *QueryRequest) (*QueryResponse, error)
	// ListQueryHandlers lists all the available query handlers.
	ListQueryHandlers(context.Context, *ListQueryHandlersRequest) (*ListQueryHandlersResponse, error)
}

ServiceServer is the server API for Service service.

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedServiceServer) ListQueryHandlers

func (*UnimplementedServiceServer) Query

Directories

Path Synopsis
Package gogoreflection implements gRPC reflection for gogoproto consumers the normal reflection library does not work as it points to a different singleton registry.
Package gogoreflection implements gRPC reflection for gogoproto consumers the normal reflection library does not work as it points to a different singleton registry.

Jump to

Keyboard shortcuts

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