dsrpc

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 13 Imported by: 2

README

go-ds-rpc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCode_name = map[int32]string{
		0:   "None",
		1:   "ErrNotFound",
		100: "Others",
	}
	ErrCode_value = map[string]int32{
		"None":        0,
		"ErrNotFound": 1,
		"Others":      100,
	}
)

Enum value maps for ErrCode.

View Source
var File_store_proto protoreflect.FileDescriptor
View Source
var KVStore_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "dsrpc.KVStore",
	HandlerType: (*KVStoreServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Put",
			Handler:    _KVStore_Put_Handler,
		},
		{
			MethodName: "Delete",
			Handler:    _KVStore_Delete_Handler,
		},
		{
			MethodName: "Get",
			Handler:    _KVStore_Get_Handler,
		},
		{
			MethodName: "Has",
			Handler:    _KVStore_Has_Handler,
		},
		{
			MethodName: "GetSize",
			Handler:    _KVStore_GetSize_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Query",
			Handler:       _KVStore_Query_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "store.proto",
}

KVStore_ServiceDesc is the grpc.ServiceDesc for KVStore service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterKVStoreServer

func RegisterKVStoreServer(s grpc.ServiceRegistrar, srv KVStoreServer)

Types

type CommonReply

type CommonReply struct {
	Code    ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=dsrpc.ErrCode" json:"code,omitempty"`
	Msg     string  `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
	Value   []byte  `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
	Success bool    `protobuf:"varint,4,opt,name=success,proto3" json:"success,omitempty"`
	Size    int64   `protobuf:"varint,5,opt,name=size,proto3" json:"size,omitempty"`
	// contains filtered or unexported fields
}

func (*CommonReply) Descriptor deprecated

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

Deprecated: Use CommonReply.ProtoReflect.Descriptor instead.

func (*CommonReply) GetCode

func (x *CommonReply) GetCode() ErrCode

func (*CommonReply) GetMsg

func (x *CommonReply) GetMsg() string

func (*CommonReply) GetSize

func (x *CommonReply) GetSize() int64

func (*CommonReply) GetSuccess

func (x *CommonReply) GetSuccess() bool

func (*CommonReply) GetValue

func (x *CommonReply) GetValue() []byte

func (*CommonReply) ProtoMessage

func (*CommonReply) ProtoMessage()

func (*CommonReply) ProtoReflect

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

func (*CommonReply) Reset

func (x *CommonReply) Reset()

func (*CommonReply) String

func (x *CommonReply) String() string

type CommonRequest

type CommonRequest struct {
	Key   string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*CommonRequest) Descriptor deprecated

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

Deprecated: Use CommonRequest.ProtoReflect.Descriptor instead.

func (*CommonRequest) GetKey

func (x *CommonRequest) GetKey() string

func (*CommonRequest) GetValue

func (x *CommonRequest) GetValue() []byte

func (*CommonRequest) ProtoMessage

func (*CommonRequest) ProtoMessage()

func (*CommonRequest) ProtoReflect

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

func (*CommonRequest) Reset

func (x *CommonRequest) Reset()

func (*CommonRequest) String

func (x *CommonRequest) String() string

type DataStore

type DataStore struct {
	// contains filtered or unexported fields
}

func NewDataStore

func NewDataStore(client KVStoreClient) (*DataStore, error)

func (DataStore) Batch

func (d DataStore) Batch(ctx context.Context) (ds.Batch, error)

func (DataStore) Close

func (d DataStore) Close() error

func (DataStore) Delete

func (d DataStore) Delete(ctx context.Context, k ds.Key) error

func (DataStore) Get

func (d DataStore) Get(ctx context.Context, k ds.Key) ([]byte, error)

func (DataStore) GetSize

func (d DataStore) GetSize(ctx context.Context, k ds.Key) (int, error)

func (DataStore) Has

func (d DataStore) Has(ctx context.Context, k ds.Key) (bool, error)

func (DataStore) Put

func (d DataStore) Put(ctx context.Context, k ds.Key, value []byte) error

func (DataStore) Query

func (d DataStore) Query(ctx context.Context, q dsq.Query) (dsq.Results, error)

func (DataStore) Sync

func (d DataStore) Sync(ctx context.Context, k ds.Key) error

type ErrCode

type ErrCode int32
const (
	ErrCode_None        ErrCode = 0
	ErrCode_ErrNotFound ErrCode = 1
	ErrCode_Others      ErrCode = 100
)

func (ErrCode) Descriptor

func (ErrCode) Descriptor() protoreflect.EnumDescriptor

func (ErrCode) Enum

func (x ErrCode) Enum() *ErrCode

func (ErrCode) EnumDescriptor deprecated

func (ErrCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use ErrCode.Descriptor instead.

func (ErrCode) Number

func (x ErrCode) Number() protoreflect.EnumNumber

func (ErrCode) String

func (x ErrCode) String() string

func (ErrCode) Type

func (ErrCode) Type() protoreflect.EnumType

type KVStoreClient

type KVStoreClient interface {
	Put(ctx context.Context, in *CommonRequest, opts ...grpc.CallOption) (*CommonReply, error)
	Delete(ctx context.Context, in *CommonRequest, opts ...grpc.CallOption) (*CommonReply, error)
	Get(ctx context.Context, in *CommonRequest, opts ...grpc.CallOption) (*CommonReply, error)
	Has(ctx context.Context, in *CommonRequest, opts ...grpc.CallOption) (*CommonReply, error)
	GetSize(ctx context.Context, in *CommonRequest, opts ...grpc.CallOption) (*CommonReply, error)
	Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (KVStore_QueryClient, error)
}

KVStoreClient is the client API for KVStore service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewKVStoreClient

func NewKVStoreClient(cc grpc.ClientConnInterface) KVStoreClient

type KVStoreServer

type KVStoreServer interface {
	Put(context.Context, *CommonRequest) (*CommonReply, error)
	Delete(context.Context, *CommonRequest) (*CommonReply, error)
	Get(context.Context, *CommonRequest) (*CommonReply, error)
	Has(context.Context, *CommonRequest) (*CommonReply, error)
	GetSize(context.Context, *CommonRequest) (*CommonReply, error)
	Query(*QueryRequest, KVStore_QueryServer) error
	// contains filtered or unexported methods
}

KVStoreServer is the server API for KVStore service. All implementations must embed UnimplementedKVStoreServer for forward compatibility

type KVStore_QueryClient

type KVStore_QueryClient interface {
	Recv() (*QueryReply, error)
	grpc.ClientStream
}

type KVStore_QueryServer

type KVStore_QueryServer interface {
	Send(*QueryReply) error
	grpc.ServerStream
}

type QueryReply

type QueryReply struct {
	Code ErrCode `protobuf:"varint,1,opt,name=code,proto3,enum=dsrpc.ErrCode" json:"code,omitempty"`
	Msg  string  `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
	Res  []byte  `protobuf:"bytes,3,opt,name=res,proto3" json:"res,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryReply) Descriptor deprecated

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

Deprecated: Use QueryReply.ProtoReflect.Descriptor instead.

func (*QueryReply) GetCode

func (x *QueryReply) GetCode() ErrCode

func (*QueryReply) GetMsg

func (x *QueryReply) GetMsg() string

func (*QueryReply) GetRes

func (x *QueryReply) GetRes() []byte

func (*QueryReply) ProtoMessage

func (*QueryReply) ProtoMessage()

func (*QueryReply) ProtoReflect

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

func (*QueryReply) Reset

func (x *QueryReply) Reset()

func (*QueryReply) String

func (x *QueryReply) String() string

type QueryRequest

type QueryRequest struct {
	Q []byte `protobuf:"bytes,1,opt,name=q,proto3" json:"q,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryRequest) Descriptor deprecated

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

Deprecated: Use QueryRequest.ProtoReflect.Descriptor instead.

func (*QueryRequest) GetQ

func (x *QueryRequest) GetQ() []byte

func (*QueryRequest) ProtoMessage

func (*QueryRequest) ProtoMessage()

func (*QueryRequest) ProtoReflect

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

func (*QueryRequest) Reset

func (x *QueryRequest) Reset()

func (*QueryRequest) String

func (x *QueryRequest) String() string

type UnimplementedKVStoreServer

type UnimplementedKVStoreServer struct {
}

UnimplementedKVStoreServer must be embedded to have forward compatible implementations.

func (UnimplementedKVStoreServer) Delete

func (UnimplementedKVStoreServer) Get

func (UnimplementedKVStoreServer) GetSize

func (UnimplementedKVStoreServer) Has

func (UnimplementedKVStoreServer) Put

func (UnimplementedKVStoreServer) Query

type UnsafeKVStoreServer

type UnsafeKVStoreServer interface {
	// contains filtered or unexported methods
}

UnsafeKVStoreServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to KVStoreServer will result in compilation errors.

Directories

Path Synopsis
cmd
plugins

Jump to

Keyboard shortcuts

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