Documentation
¶
Index ¶
- Constants
- Variables
- func InitLog(output, loglevel string) error
- func ListenAndServe(proto string, addr string) error
- func Log(status, msg string, ses *Session, err error)
- func NewIDGenerator(workerID uint) error
- func NewLogger(output, loglevel string) error
- func NewMainStore()
- func NewMainStoreEnableSyncRemote()
- func RegisterSyncServer(s grpc.ServiceRegistrar, srv SyncServer)
- func RunExpireChecker(ctx context.Context)
- func RunSyncRemote(ctx context.Context, hosts []string)
- func ServeTCP(l *net.TCPListener) error
- func ServeUDP(c *net.UDPConn) error
- type Buffer
- type BufferPool
- type Client
- type ClientConfig
- type MemStore
- func (ms MemStore) Count() int
- func (ms MemStore) Del(k string) bool
- func (ms MemStore) Get(k string) (*StoreData, error)
- func (ms MemStore) Items() map[string]*StoreData
- func (ms MemStore) ItemsJSON() ([]byte, error)
- func (ms MemStore) Set(k string, w *StoreData)
- func (ms MemStore) SyncDel(k string) bool
- func (ms MemStore) SyncSet(k string, w *StoreData)
- type MethodType
- type ProtocolType
- type Response
- type ResultType
- type ServerConfig
- type ServerCtl
- type ServerCtlConfig
- type Session
- type Store
- type StoreData
- type Sync
- type SyncClient
- type SyncServer
- type TCPServer
- type UDPServer
- type UnimplementedSyncServer
- type UnsafeSyncServer
- type WSDumpRequest
- type WSDumpResponse
- func (*WSDumpResponse) Descriptor() ([]byte, []int)deprecated
- func (x *WSDumpResponse) GetJson() []byte
- func (x *WSDumpResponse) GetMsg() string
- func (x *WSDumpResponse) GetRcode() int32
- func (*WSDumpResponse) ProtoMessage()
- func (x *WSDumpResponse) ProtoReflect() protoreflect.Message
- func (x *WSDumpResponse) Reset()
- func (x *WSDumpResponse) String() string
- type WSRequest
- func (*WSRequest) Descriptor() ([]byte, []int)deprecated
- func (x *WSRequest) GetData() string
- func (x *WSRequest) GetExpire() int64
- func (x *WSRequest) GetIP() string
- func (x *WSRequest) GetMethod() string
- func (*WSRequest) ProtoMessage()
- func (x *WSRequest) ProtoReflect() protoreflect.Message
- func (x *WSRequest) Reset()
- func (x *WSRequest) String() string
- type WSResponse
- type Worker
Constants ¶
Variables ¶
var ( // MainStore holds main store. MainStore Store // Logger halds logging. Logger *zap.Logger // LogWriter is IO Writer. LogWriter reopen.Writer // IDGenerator halds id generator. IDGenerator katsubushi.Generator // ExpvarMap halds expvar map. ExpvarMap = expvar.NewMap("gowhoson") )
var File_pkg_whoson_sync_proto protoreflect.FileDescriptor
var Sync_ServiceDesc = grpc.ServiceDesc{ ServiceName: "whoson.sync", HandlerType: (*SyncServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Set", Handler: _Sync_Set_Handler, }, { MethodName: "Del", Handler: _Sync_Del_Handler, }, { MethodName: "Dump", Handler: _Sync_Dump_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "pkg/whoson/sync.proto", }
Sync_ServiceDesc is the grpc.ServiceDesc for Sync service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func ListenAndServe ¶
ListenAndServe simple start whoson server TCP or UDP.
func NewIDGenerator ¶
NewIDGenerator is set id generator to IDGenerator.
func NewMainStoreEnableSyncRemote ¶
func NewMainStoreEnableSyncRemote()
NewMainStoreEnableSyncRemote set MemStore to MainStore, enable sync remote.
func RegisterSyncServer ¶
func RegisterSyncServer(s grpc.ServiceRegistrar, srv SyncServer)
func RunExpireChecker ¶
RunExpireChecker Check expire for all cmap store data.
func RunSyncRemote ¶
RunSyncRemote is sync data to remote grpc servers.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer hold information for buffer pool.
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool hold information for sync.Pool.
func NewBufferPool ¶
func NewBufferPool() *BufferPool
NewBufferPool return new BufferPool struct pointer.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client hold information for whoson API client.
type ClientConfig ¶
ClientConfig hold information for client configration.
type MemStore ¶
MemStore hold information for cmap.
type Response ¶
type Response struct { Msg string // contains filtered or unexported fields }
Response hold information for response values.
type ServerConfig ¶
type ServerConfig struct { TCP string UDP string Log string Loglevel string ServerID int Expvar bool ControlPort string SyncRemote string SaveFile string }
ServerConfig hold information for server configration.
type ServerCtl ¶
type ServerCtl struct {
// contains filtered or unexported fields
}
ServerCtl hold information for server control.
func NewServerCtl ¶
NewServerCtl return new ServerCtl struct pointer.
func (*ServerCtl) WriteTable ¶
WriteTable Output Table with io.Writer
type ServerCtlConfig ¶
ServerCtlConfig hold information for serverctl configration.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session hold information for whoson session.
func NewSessionTCP ¶
NewSessionTCP return new Session struct pointer for TCP.
type Store ¶
type Store interface { Set(k string, w *StoreData) Get(k string) (*StoreData, error) Del(k string) bool Items() map[string]*StoreData ItemsJSON() ([]byte, error) Count() int SyncSet(k string, w *StoreData) SyncDel(k string) bool }
Store is hold Store API.
type StoreData ¶
StoreData hold information for whoson data.
func (*StoreData) UpdateExpire ¶
func (sd *StoreData) UpdateExpire()
UpdateExpire Update stored data of expire time.
type Sync ¶
type Sync struct {
UnimplementedSyncServer
}
Sync hold information for synchronization.
func (*Sync) Dump ¶
func (s *Sync) Dump(c context.Context, wreq *WSDumpRequest) (*WSDumpResponse, error)
Dump dump to all data
type SyncClient ¶
type SyncClient interface { Set(ctx context.Context, in *WSRequest, opts ...grpc.CallOption) (*WSResponse, error) Del(ctx context.Context, in *WSRequest, opts ...grpc.CallOption) (*WSResponse, error) Dump(ctx context.Context, in *WSDumpRequest, opts ...grpc.CallOption) (*WSDumpResponse, error) }
SyncClient is the client API for Sync 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 NewSyncClient ¶
func NewSyncClient(cc grpc.ClientConnInterface) SyncClient
type SyncServer ¶
type SyncServer interface { Set(context.Context, *WSRequest) (*WSResponse, error) Del(context.Context, *WSRequest) (*WSResponse, error) Dump(context.Context, *WSDumpRequest) (*WSDumpResponse, error) // contains filtered or unexported methods }
SyncServer is the server API for Sync service. All implementations must embed UnimplementedSyncServer for forward compatibility
type TCPServer ¶
type TCPServer struct { Addr string // contains filtered or unexported fields }
TCPServer hold information for tcp server.
func NewTCPServer ¶
func NewTCPServer() *TCPServer
NewTCPServer return new TCPServer struct pointer.
func (*TCPServer) ListenAndServe ¶
ListenAndServe simple start tcp server.
type UDPServer ¶
type UDPServer struct { Addr string // contains filtered or unexported fields }
UDPServer hold information for udp server.
func NewUDPServer ¶
func NewUDPServer() *UDPServer
NewUDPServer return new UDPServer struct pointer.
func (*UDPServer) ListenAndServe ¶
ListenAndServe simple start udp server.
type UnimplementedSyncServer ¶ added in v0.2.7
type UnimplementedSyncServer struct { }
UnimplementedSyncServer must be embedded to have forward compatible implementations.
func (UnimplementedSyncServer) Del ¶ added in v0.2.7
func (UnimplementedSyncServer) Del(context.Context, *WSRequest) (*WSResponse, error)
func (UnimplementedSyncServer) Dump ¶ added in v0.2.7
func (UnimplementedSyncServer) Dump(context.Context, *WSDumpRequest) (*WSDumpResponse, error)
func (UnimplementedSyncServer) Set ¶ added in v0.2.7
func (UnimplementedSyncServer) Set(context.Context, *WSRequest) (*WSResponse, error)
type UnsafeSyncServer ¶ added in v0.2.7
type UnsafeSyncServer interface {
// contains filtered or unexported methods
}
UnsafeSyncServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to SyncServer will result in compilation errors.
type WSDumpRequest ¶
type WSDumpRequest struct {
// contains filtered or unexported fields
}
func (*WSDumpRequest) Descriptor
deprecated
func (*WSDumpRequest) Descriptor() ([]byte, []int)
Deprecated: Use WSDumpRequest.ProtoReflect.Descriptor instead.
func (*WSDumpRequest) ProtoMessage ¶
func (*WSDumpRequest) ProtoMessage()
func (*WSDumpRequest) ProtoReflect ¶ added in v0.2.7
func (x *WSDumpRequest) ProtoReflect() protoreflect.Message
func (*WSDumpRequest) Reset ¶
func (x *WSDumpRequest) Reset()
func (*WSDumpRequest) String ¶
func (x *WSDumpRequest) String() string
type WSDumpResponse ¶
type WSDumpResponse struct { Rcode int32 `protobuf:"varint,1,opt,name=Rcode,proto3" json:"Rcode,omitempty"` Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` Json []byte `protobuf:"bytes,3,opt,name=Json,proto3" json:"Json,omitempty"` // contains filtered or unexported fields }
func (*WSDumpResponse) Descriptor
deprecated
func (*WSDumpResponse) Descriptor() ([]byte, []int)
Deprecated: Use WSDumpResponse.ProtoReflect.Descriptor instead.
func (*WSDumpResponse) GetJson ¶ added in v0.2.7
func (x *WSDumpResponse) GetJson() []byte
func (*WSDumpResponse) GetMsg ¶ added in v0.2.7
func (x *WSDumpResponse) GetMsg() string
func (*WSDumpResponse) GetRcode ¶ added in v0.2.7
func (x *WSDumpResponse) GetRcode() int32
func (*WSDumpResponse) ProtoMessage ¶
func (*WSDumpResponse) ProtoMessage()
func (*WSDumpResponse) ProtoReflect ¶ added in v0.2.7
func (x *WSDumpResponse) ProtoReflect() protoreflect.Message
func (*WSDumpResponse) Reset ¶
func (x *WSDumpResponse) Reset()
func (*WSDumpResponse) String ¶
func (x *WSDumpResponse) String() string
type WSRequest ¶
type WSRequest struct { Expire int64 `protobuf:"varint,1,opt,name=Expire,proto3" json:"Expire,omitempty"` IP string `protobuf:"bytes,2,opt,name=IP,proto3" json:"IP,omitempty"` Data string `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` Method string `protobuf:"bytes,4,opt,name=Method,proto3" json:"Method,omitempty"` // contains filtered or unexported fields }
func (*WSRequest) Descriptor
deprecated
func (*WSRequest) ProtoMessage ¶
func (*WSRequest) ProtoMessage()
func (*WSRequest) ProtoReflect ¶ added in v0.2.7
func (x *WSRequest) ProtoReflect() protoreflect.Message
type WSResponse ¶
type WSResponse struct { Rcode int32 `protobuf:"varint,1,opt,name=Rcode,proto3" json:"Rcode,omitempty"` Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` // contains filtered or unexported fields }
func (*WSResponse) Descriptor
deprecated
func (*WSResponse) Descriptor() ([]byte, []int)
Deprecated: Use WSResponse.ProtoReflect.Descriptor instead.
func (*WSResponse) GetMsg ¶ added in v0.2.7
func (x *WSResponse) GetMsg() string
func (*WSResponse) GetRcode ¶ added in v0.2.7
func (x *WSResponse) GetRcode() int32
func (*WSResponse) ProtoMessage ¶
func (*WSResponse) ProtoMessage()
func (*WSResponse) ProtoReflect ¶ added in v0.2.7
func (x *WSResponse) ProtoReflect() protoreflect.Message
func (*WSResponse) Reset ¶
func (x *WSResponse) Reset()
func (*WSResponse) String ¶
func (x *WSResponse) String() string