Documentation ¶
Index ¶
- Constants
- Variables
- func AddSlot()
- func ComplementHex(s string, x int) string
- func CreateLocalPWD() []byte
- func CreateNewId(length int) []byte
- func CreateUUID(length int, xtr []byte, self []byte) []byte
- func Decrypt(s []byte) []byte
- func DeleteRpc(args *OperationArgs, address string) []byte
- func DropSlot()
- func EchoNoKeepAlive(c net.Conn, slot *Slot)
- func Encrypt(string2 []byte) []byte
- func EntryDelete(key []byte) []byte
- func EntryGet(key []byte) []byte
- func EntryHashDelete(key []byte) []byte
- func EntryHashGet(key []byte) []byte
- func EntryHashSet(key, value []byte, ti int) []byte
- func EntrySet(key, value []byte, ti int) []byte
- func Equal(one []byte, two []byte) bool
- func FindAll(n []*node) []byte
- func FindString(v []byte, p []byte) interface{}
- func GetData(a net.Conn) []byte
- func GetRpc(args *OperationArgs, address string) []byte
- func MD5(b []byte) []byte
- func NewClockTask(e int64) *clockTask
- func NewDial() *ap.Pool
- func NoRpcServer(config *Config)
- func ParsingExpirationDate(tm interface{}) interface{}
- func RegisterOperationServer(s *grpc.Server, srv OperationServer)
- func RegisterWatcherServer(s *grpc.Server, srv WatcherServer)
- func ReplaceTabCharacter(in []byte) []byte
- func ReplaceTabCharacterToNormal(in []byte) []byte
- func RpcStart(config Config)
- func SendDeleteMessage()
- func SendGetMessage(key []byte) []byte
- func SendSetMessage(lang []byte, ti []byte) []byte
- func SetRpc(args *OperationArgs, address string) int
- func SplitKeyValue(b []byte) ([]byte, []byte)
- func SplitString(str []byte, p []byte) [][]byte
- func ToBytes(x interface{}) ([]byte, error)
- type Config
- type DNode
- type DeleteResult
- type FileConfig
- type Hash
- func (h *Hash) Clone() int
- func (h *Hash) Delete(key []byte) []byte
- func (h *Hash) Get(key []byte) interface{}
- func (h *Hash) GetAll() []interface{}
- func (h *Hash) GetHashPos(str []byte) uint
- func (h *Hash) Load()
- func (h *Hash) Reload()
- func (h *Hash) Set(key []byte, value interface{}, expTime int64) int
- func (h *Hash) Storage()
- type Operation
- type OperationArgs
- func (*OperationArgs) Descriptor() ([]byte, []int)deprecated
- func (x *OperationArgs) GetExpiration() int64
- func (x *OperationArgs) GetKey() []byte
- func (x *OperationArgs) GetValue() []byte
- func (*OperationArgs) ProtoMessage()
- func (x *OperationArgs) ProtoReflect() protoreflect.Message
- func (x *OperationArgs) Reset()
- func (x *OperationArgs) String() string
- type OperationClient
- type OperationServer
- type Result
- type SetResult
- type Slot
- type UnimplementedOperationServer
- type UnimplementedWatcherServer
- type Watcher
- type WatcherClient
- type WatcherData
- type WatcherResult
- type WatcherServer
Constants ¶
const ( FILE = iota MEMORY )
Variables ¶
var CRY []uint
var File_remote_operation_proto protoreflect.FileDescriptor
Functions ¶
func ComplementHex ¶
func CreateLocalPWD ¶
func CreateLocalPWD() []byte
func CreateNewId ¶
func DeleteRpc ¶
func DeleteRpc(args *OperationArgs, address string) []byte
func EchoNoKeepAlive ¶
func EntryDelete ¶
func EntryHashDelete ¶
func EntryHashGet ¶
func EntryHashSet ¶
func FindString ¶
func GetRpc ¶
func GetRpc(args *OperationArgs, address string) []byte
func NewClockTask ¶
func NewClockTask(e int64) *clockTask
func NoRpcServer ¶
func NoRpcServer(config *Config)
func ParsingExpirationDate ¶
func ParsingExpirationDate(tm interface{}) interface{}
func RegisterOperationServer ¶
func RegisterOperationServer(s *grpc.Server, srv OperationServer)
func RegisterWatcherServer ¶
func RegisterWatcherServer(s *grpc.Server, srv WatcherServer)
func ReplaceTabCharacter ¶
replace tab character function \n -> 0 \r -> 1 \t -> 2
func SendDeleteMessage ¶
func SendDeleteMessage()
func SendGetMessage ¶
func SendSetMessage ¶
func SetRpc ¶
func SetRpc(args *OperationArgs, address string) int
func SplitKeyValue ¶
传输协议的制定 0-> 表示操作码 1 状态码 2-3 过期时间 4-10 暂时没想到 11-N 语句 操作码 0 delete | 1 set | 2 get | 3 status 状态码 0 操作失败 1操作成功 2 操作中 set key 和 value 以0作为分割 新加 2-3 存放过期时间 最大 0xFFFF or 65535
func SplitString ¶
func CheckConfig(nw interface{}, deft interface{}) { switch reflect.TypeOf(nw).Kind() { case reflect.Struct: t := reflect.TypeOf(nw).Elem() v := reflect.ValueOf(nw).Elem() for i := 0; i < t.NumField(); i++ { n := v.Field(i) switch n.Kind() { case reflect.String: if n.IsZero() { n.SetString(reflect.ValueOf(deft).Field(i).String()) } case reflect.Int: if n.IsZero() { n.SetInt(reflect.ValueOf(deft).Field(i).Int()) } case reflect.Int64: if n.IsZero() { n.SetInt(reflect.ValueOf(deft).Field(i).Int()) } case reflect.Bool: if n.IsZero() { n.SetBool(reflect.ValueOf(deft).Field(i).Bool()) } case reflect.Float64: if n.IsZero() { n.SetFloat(reflect.ValueOf(deft).Field(i).Float()) } } } case reflect.Ptr: n := reflect.ValueOf(nw).Elem() switch n.Kind() { case reflect.Int: if n.IsZero() && n.CanSet() { n.SetInt(reflect.ValueOf(deft).Int()) } case reflect.String: if n.IsZero() && n.CanSet() { n.SetString(reflect.ValueOf(deft).String()) } case reflect.Struct: t := reflect.TypeOf(nw).Elem() v := reflect.ValueOf(nw).Elem() for i := 0; i < t.NumField(); i++ { n := v.Field(i) switch n.Kind() { case reflect.String: if n.IsZero() { n.SetString(reflect.ValueOf(deft).Field(i).String()) } case reflect.Int: if n.IsZero() { n.SetInt(reflect.ValueOf(deft).Field(i).Int()) } case reflect.Int64: if n.IsZero() { n.SetInt(reflect.ValueOf(deft).Field(i).Int()) } case reflect.Bool: if n.IsZero() { n.SetBool(reflect.ValueOf(deft).Field(i).Bool()) } case reflect.Float64: if n.IsZero() { n.SetFloat(reflect.ValueOf(deft).Field(i).Float()) } } } } } }
Types ¶
type DNode ¶
type DNode struct { Name string `yaml:"name"` Ip string `yaml:"ip"` Weigh int `yaml:"weigh"` Password string `yaml:"password"` }
type DCSConfig struct { Name string `json:"name"` Ip string `json:"ip"` Weigh int `json:"weigh"` Password string `json:"password"` }
func ParseConfigFile ¶
type DeleteResult ¶
type DeleteResult struct { Value []byte `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"` // contains filtered or unexported fields }
func (*DeleteResult) Descriptor
deprecated
func (*DeleteResult) Descriptor() ([]byte, []int)
Deprecated: Use DeleteResult.ProtoReflect.Descriptor instead.
func (*DeleteResult) GetValue ¶
func (x *DeleteResult) GetValue() []byte
func (*DeleteResult) ProtoMessage ¶
func (*DeleteResult) ProtoMessage()
func (*DeleteResult) ProtoReflect ¶
func (x *DeleteResult) ProtoReflect() protoreflect.Message
func (*DeleteResult) Reset ¶
func (x *DeleteResult) Reset()
func (*DeleteResult) String ¶
func (x *DeleteResult) String() string
type FileConfig ¶
type FileConfig struct {
Config []DNode `yaml:"config"`
}
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
func CreateHash ¶
func (*Hash) GetHashPos ¶
type Operation ¶
type Operation struct {
UnimplementedOperationServer
}
func (*Operation) Delete ¶
func (o *Operation) Delete(ctx context.Context, in *OperationArgs) (*DeleteResult, error)
type OperationArgs ¶
type OperationArgs struct { Key []byte `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=Value,proto3" json:"Value,omitempty"` Expiration int64 `protobuf:"varint,3,opt,name=Expiration,proto3" json:"Expiration,omitempty"` // contains filtered or unexported fields }
func (*OperationArgs) Descriptor
deprecated
func (*OperationArgs) Descriptor() ([]byte, []int)
Deprecated: Use OperationArgs.ProtoReflect.Descriptor instead.
func (*OperationArgs) GetExpiration ¶
func (x *OperationArgs) GetExpiration() int64
func (*OperationArgs) GetKey ¶
func (x *OperationArgs) GetKey() []byte
func (*OperationArgs) GetValue ¶
func (x *OperationArgs) GetValue() []byte
func (*OperationArgs) ProtoMessage ¶
func (*OperationArgs) ProtoMessage()
func (*OperationArgs) ProtoReflect ¶
func (x *OperationArgs) ProtoReflect() protoreflect.Message
func (*OperationArgs) Reset ¶
func (x *OperationArgs) Reset()
func (*OperationArgs) String ¶
func (x *OperationArgs) String() string
type OperationClient ¶
type OperationClient interface { Get(ctx context.Context, in *OperationArgs, opts ...grpc.CallOption) (*Result, error) Set(ctx context.Context, in *OperationArgs, opts ...grpc.CallOption) (*SetResult, error) Delete(ctx context.Context, in *OperationArgs, opts ...grpc.CallOption) (*DeleteResult, error) }
OperationClient is the client API for Operation service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewOperationClient ¶
func NewOperationClient(cc grpc.ClientConnInterface) OperationClient
type OperationServer ¶
type OperationServer interface { Get(context.Context, *OperationArgs) (*Result, error) Set(context.Context, *OperationArgs) (*SetResult, error) Delete(context.Context, *OperationArgs) (*DeleteResult, error) }
OperationServer is the server API for Operation service.
type Result ¶
type Result struct { Value []byte `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"` // contains filtered or unexported fields }
func (*Result) Descriptor
deprecated
func (*Result) ProtoMessage ¶
func (*Result) ProtoMessage()
func (*Result) ProtoReflect ¶
func (x *Result) ProtoReflect() protoreflect.Message
type SetResult ¶
type SetResult struct { Position int64 `protobuf:"varint,1,opt,name=Position,proto3" json:"Position,omitempty"` // contains filtered or unexported fields }
func (*SetResult) Descriptor
deprecated
func (*SetResult) GetPosition ¶
func (*SetResult) ProtoMessage ¶
func (*SetResult) ProtoMessage()
func (*SetResult) ProtoReflect ¶
func (x *SetResult) ProtoReflect() protoreflect.Message
type Slot ¶
type UnimplementedOperationServer ¶
type UnimplementedOperationServer struct { }
UnimplementedOperationServer can be embedded to have forward compatible implementations.
func (*UnimplementedOperationServer) Delete ¶
func (*UnimplementedOperationServer) Delete(context.Context, *OperationArgs) (*DeleteResult, error)
func (*UnimplementedOperationServer) Get ¶
func (*UnimplementedOperationServer) Get(context.Context, *OperationArgs) (*Result, error)
func (*UnimplementedOperationServer) Set ¶
func (*UnimplementedOperationServer) Set(context.Context, *OperationArgs) (*SetResult, error)
type UnimplementedWatcherServer ¶
type UnimplementedWatcherServer struct { }
UnimplementedWatcherServer can be embedded to have forward compatible implementations.
func (*UnimplementedWatcherServer) Pong ¶
func (*UnimplementedWatcherServer) Pong(context.Context, *WatcherData) (*WatcherResult, error)
type Watcher ¶
type Watcher struct {
UnimplementedWatcherServer
}
func (*Watcher) Pong ¶
func (w *Watcher) Pong(ctx context.Context, in *WatcherData) (*WatcherResult, error)
func (w *Watcher) Ping(ip string) int8 {
}
type WatcherClient ¶
type WatcherClient interface {
Pong(ctx context.Context, in *WatcherData, opts ...grpc.CallOption) (*WatcherResult, error)
}
WatcherClient is the client API for Watcher service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewWatcherClient ¶
func NewWatcherClient(cc grpc.ClientConnInterface) WatcherClient
type WatcherData ¶
type WatcherData struct { Time int64 `protobuf:"varint,1,opt,name=Time,proto3" json:"Time,omitempty"` // contains filtered or unexported fields }
func (*WatcherData) Descriptor
deprecated
func (*WatcherData) Descriptor() ([]byte, []int)
Deprecated: Use WatcherData.ProtoReflect.Descriptor instead.
func (*WatcherData) GetTime ¶
func (x *WatcherData) GetTime() int64
func (*WatcherData) ProtoMessage ¶
func (*WatcherData) ProtoMessage()
func (*WatcherData) ProtoReflect ¶
func (x *WatcherData) ProtoReflect() protoreflect.Message
func (*WatcherData) Reset ¶
func (x *WatcherData) Reset()
func (*WatcherData) String ¶
func (x *WatcherData) String() string
type WatcherResult ¶
type WatcherResult struct { Res int64 `protobuf:"varint,1,opt,name=Res,proto3" json:"Res,omitempty"` // contains filtered or unexported fields }
func (*WatcherResult) Descriptor
deprecated
func (*WatcherResult) Descriptor() ([]byte, []int)
Deprecated: Use WatcherResult.ProtoReflect.Descriptor instead.
func (*WatcherResult) GetRes ¶
func (x *WatcherResult) GetRes() int64
func (*WatcherResult) ProtoMessage ¶
func (*WatcherResult) ProtoMessage()
func (*WatcherResult) ProtoReflect ¶
func (x *WatcherResult) ProtoReflect() protoreflect.Message
func (*WatcherResult) Reset ¶
func (x *WatcherResult) Reset()
func (*WatcherResult) String ¶
func (x *WatcherResult) String() string
type WatcherServer ¶
type WatcherServer interface {
Pong(context.Context, *WatcherData) (*WatcherResult, error)
}
WatcherServer is the server API for Watcher service.