grpc

package
Version: v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: GPL-3.0 Imports: 16 Imported by: 8

README

How to generate klaytn.pb.go from klaytn.proto

1. Install protobuf for Go

$ go get -u github.com/golang/protobuf/protoc-gen-go

2. Generate a Go file from protobuf IDL

$ protoc -I=. --go_out=plugins=grpc:. klaytn.proto

3. Change the generated file

Because of version mismatch issue, we need to change proto.ProtoPackageIsVersion3 in the generated file klaytn.pb.go to proto.ProtoPackageIsVersion2.

$ sed -i -e 's/ProtoPackageIsVersion3/ProtoPackageIsVersion2/g' klaytn.pb.go

Documentation

Overview

Package grpc implements the gRPC protocol for Klaytn.

This package allows you to use Klaytn's RPC API using gRPC. See below for gRPC: https://grpc.io/docs/quickstart/go/

Source files

Each file provides the following features

- gClient.go : gRPC client implementation.
- gServer.go : gRPC server implementation.
- klaytn.proto : Define a interface and messages to use in gRPC server and clients.
- klaytn.pb.go : the generated Go file from klaytn.proto by protoc-gen-go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewgKlaytnClient

func NewgKlaytnClient(addr string) (*gKlaytnClient, error)

func RegisterKlaytnNodeServer

func RegisterKlaytnNodeServer(s *grpc.Server, srv KlaytnNodeServer)

Types

type Empty

type Empty struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Empty) Descriptor

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

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) String

func (m *Empty) String() string

func (*Empty) XXX_DiscardUnknown

func (m *Empty) XXX_DiscardUnknown()

func (*Empty) XXX_Marshal

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

func (*Empty) XXX_Merge

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

func (*Empty) XXX_Size

func (m *Empty) XXX_Size() int

func (*Empty) XXX_Unmarshal

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

type KlaytnNodeClient

type KlaytnNodeClient interface {
	Call(ctx context.Context, in *RPCRequest, opts ...grpc.CallOption) (*RPCResponse, error)
	Subscribe(ctx context.Context, in *RPCRequest, opts ...grpc.CallOption) (KlaytnNode_SubscribeClient, error)
	BiCall(ctx context.Context, opts ...grpc.CallOption) (KlaytnNode_BiCallClient, error)
}

KlaytnNodeClient is the client API for KlaytnNode service.

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

func NewKlaytnNodeClient

func NewKlaytnNodeClient(cc *grpc.ClientConn) KlaytnNodeClient

type KlaytnNodeServer

type KlaytnNodeServer interface {
	Call(context.Context, *RPCRequest) (*RPCResponse, error)
	Subscribe(*RPCRequest, KlaytnNode_SubscribeServer) error
	BiCall(KlaytnNode_BiCallServer) error
}

KlaytnNodeServer is the server API for KlaytnNode service.

type KlaytnNode_BiCallClient

type KlaytnNode_BiCallClient interface {
	Send(*RPCRequest) error
	Recv() (*RPCResponse, error)
	grpc.ClientStream
}

type KlaytnNode_BiCallServer

type KlaytnNode_BiCallServer interface {
	Send(*RPCResponse) error
	Recv() (*RPCRequest, error)
	grpc.ServerStream
}

type KlaytnNode_SubscribeClient

type KlaytnNode_SubscribeClient interface {
	Recv() (*RPCResponse, error)
	grpc.ClientStream
}

type KlaytnNode_SubscribeServer

type KlaytnNode_SubscribeServer interface {
	Send(*RPCResponse) error
	grpc.ServerStream
}

type Listener

type Listener struct {
	Addr string
	// contains filtered or unexported fields
}

func (*Listener) SetRPCServer

func (gs *Listener) SetRPCServer(handler *rpc.Server)

SetRPCServer sets the RPC server.

func (*Listener) Start

func (gs *Listener) Start()

func (*Listener) Stop

func (gs *Listener) Stop()

type RPCRequest

type RPCRequest struct {
	Service              string   `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	Method               string   `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	Params               []byte   `protobuf:"bytes,3,opt,name=params,proto3" json:"params,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RPCRequest) Descriptor

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

func (*RPCRequest) GetMethod

func (m *RPCRequest) GetMethod() string

func (*RPCRequest) GetParams

func (m *RPCRequest) GetParams() []byte

func (*RPCRequest) GetService

func (m *RPCRequest) GetService() string

func (*RPCRequest) ProtoMessage

func (*RPCRequest) ProtoMessage()

func (*RPCRequest) Reset

func (m *RPCRequest) Reset()

func (*RPCRequest) String

func (m *RPCRequest) String() string

func (*RPCRequest) XXX_DiscardUnknown

func (m *RPCRequest) XXX_DiscardUnknown()

func (*RPCRequest) XXX_Marshal

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

func (*RPCRequest) XXX_Merge

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

func (*RPCRequest) XXX_Size

func (m *RPCRequest) XXX_Size() int

func (*RPCRequest) XXX_Unmarshal

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

type RPCResponse

type RPCResponse struct {
	Payload              []byte   `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RPCResponse) Descriptor

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

func (*RPCResponse) GetPayload

func (m *RPCResponse) GetPayload() []byte

func (*RPCResponse) ProtoMessage

func (*RPCResponse) ProtoMessage()

func (*RPCResponse) Reset

func (m *RPCResponse) Reset()

func (*RPCResponse) String

func (m *RPCResponse) String() string

func (*RPCResponse) XXX_DiscardUnknown

func (m *RPCResponse) XXX_DiscardUnknown()

func (*RPCResponse) XXX_Marshal

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

func (*RPCResponse) XXX_Merge

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

func (*RPCResponse) XXX_Size

func (m *RPCResponse) XXX_Size() int

func (*RPCResponse) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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