Documentation ¶
Index ¶
- type MarshalFunc
- type MetaManager
- type MockCodec
- type NodeSession
- type NodeSessionCreator
- type NodeType
- type PegasusCodec
- type PegasusRpcCall
- type ReplicaManager
- type ReplicaSession
- func (rs *ReplicaSession) CheckAndSet(ctx context.Context, gpid *base.Gpid, request *rrdb.CheckAndSetRequest) (*rrdb.CheckAndSetResponse, error)
- func (rs *ReplicaSession) ClearScanner(ctx context.Context, gpid *base.Gpid, contextId int64) error
- func (rs *ReplicaSession) Del(ctx context.Context, gpid *base.Gpid, key *base.Blob) (*rrdb.UpdateResponse, error)
- func (rs *ReplicaSession) Get(ctx context.Context, gpid *base.Gpid, key *base.Blob) (*rrdb.ReadResponse, error)
- func (rs *ReplicaSession) GetScanner(ctx context.Context, gpid *base.Gpid, request *rrdb.GetScannerRequest) (*rrdb.ScanResponse, error)
- func (rs *ReplicaSession) MultiDelete(ctx context.Context, gpid *base.Gpid, request *rrdb.MultiRemoveRequest) (*rrdb.MultiRemoveResponse, error)
- func (rs *ReplicaSession) MultiGet(ctx context.Context, gpid *base.Gpid, request *rrdb.MultiGetRequest) (*rrdb.MultiGetResponse, error)
- func (rs *ReplicaSession) MultiSet(ctx context.Context, gpid *base.Gpid, request *rrdb.MultiPutRequest) (*rrdb.UpdateResponse, error)
- func (rs *ReplicaSession) Put(ctx context.Context, gpid *base.Gpid, key *base.Blob, value *base.Blob, ...) (*rrdb.UpdateResponse, error)
- func (rs *ReplicaSession) Scan(ctx context.Context, gpid *base.Gpid, request *rrdb.ScanRequest) (*rrdb.ScanResponse, error)
- func (rs *ReplicaSession) SortKeyCount(ctx context.Context, gpid *base.Gpid, hashKey *base.Blob) (*rrdb.CountResponse, error)
- func (rs *ReplicaSession) TTL(ctx context.Context, gpid *base.Gpid, key *base.Blob) (*rrdb.TTLResponse, error)
- type RpcRequestArgs
- type RpcResponseResult
- type UnmarshalFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MarshalFunc ¶
type MetaManager ¶
type MetaManager struct {
// contains filtered or unexported fields
}
MetaManager manages the list of metas, but only the leader will it requests to. If the one is not the actual leader, it will retry with another.
func NewMetaManager ¶
func NewMetaManager(addrs []string, creator NodeSessionCreator) *MetaManager
func (*MetaManager) Close ¶
func (m *MetaManager) Close() error
func (*MetaManager) QueryConfig ¶
func (m *MetaManager) QueryConfig(ctx context.Context, tableName string) (*replication.QueryCfgResponse, error)
Thread-Safe
type MockCodec ¶
type MockCodec struct {
// contains filtered or unexported fields
}
MockCodec is only used for testing. By default it does nothing on marshalling and unmarshalling, thus it returns no error even if the input was ill-formed.
func (*MockCodec) MockMarshal ¶
func (p *MockCodec) MockMarshal(marshal MarshalFunc)
func (*MockCodec) MockUnMarshal ¶
func (p *MockCodec) MockUnMarshal(unmarshal UnmarshalFunc)
type NodeSession ¶
type NodeSession interface { String() string // Invoke an rpc call. CallWithGpid(ctx context.Context, gpid *base.Gpid, args RpcRequestArgs, name string) (result RpcResponseResult, err error) // Get connection state. ConnState() rpc.ConnState Close() error }
NodeSession represents the network session to a node (either a meta server or a replica server). It encapsulates the internal rpc process, including network communication and message (de)serialization.
func NewNodeSession ¶
func NewNodeSession(addr string, ntype NodeType) NodeSession
NewNodeSession always returns a non-nil value even when the connection attempt failed. Each nodeSession corresponds to an RpcConn.
type NodeSessionCreator ¶
type NodeSessionCreator func(string, NodeType) NodeSession
NodeSessionCreator creates an instance of NodeSession, receiving argument `string` as host address, `NodeType` as type of the node.
type NodeType ¶
type NodeType string
const ( NodeTypeMeta NodeType = "meta" NodeTypeReplica = "replica" )
type PegasusCodec ¶
type PegasusCodec struct {
// contains filtered or unexported fields
}
func NewPegasusCodec ¶
func NewPegasusCodec() *PegasusCodec
func (*PegasusCodec) Marshal ¶
func (p *PegasusCodec) Marshal(v interface{}) ([]byte, error)
func (*PegasusCodec) String ¶
func (p *PegasusCodec) String() string
func (*PegasusCodec) Unmarshal ¶
func (p *PegasusCodec) Unmarshal(data []byte, v interface{}) error
type PegasusRpcCall ¶
type PegasusRpcCall struct { Args RpcRequestArgs Result RpcResponseResult Name string // the rpc's name SeqId int32 Gpid *base.Gpid RawReq []byte // the marshalled request in bytes Err error }
func MarshallPegasusRpc ¶
func MarshallPegasusRpc(codec rpc.Codec, seqId int32, gpid *base.Gpid, args RpcRequestArgs, name string) (*PegasusRpcCall, error)
func ReadRpcResponse ¶
type ReplicaManager ¶
ReplicaManager manages the pool of sessions to replica servers, so that different tables that locate on the same replica server can share one ReplicaSession, without the effort of creating a new connection.
func NewReplicaManager ¶
func NewReplicaManager(creator NodeSessionCreator) *ReplicaManager
func (*ReplicaManager) Close ¶
func (rm *ReplicaManager) Close() error
func (*ReplicaManager) GetReplica ¶
func (rm *ReplicaManager) GetReplica(addr string) *ReplicaSession
Create a new session to the replica server if no existing one.
func (*ReplicaManager) ReplicaCount ¶
func (rm *ReplicaManager) ReplicaCount() int
type ReplicaSession ¶
type ReplicaSession struct {
NodeSession
}
ReplicaSession represents the network session between client and replica server.
func (*ReplicaSession) CheckAndSet ¶
func (rs *ReplicaSession) CheckAndSet(ctx context.Context, gpid *base.Gpid, request *rrdb.CheckAndSetRequest) (*rrdb.CheckAndSetResponse, error)
func (*ReplicaSession) ClearScanner ¶
func (*ReplicaSession) Del ¶
func (rs *ReplicaSession) Del(ctx context.Context, gpid *base.Gpid, key *base.Blob) (*rrdb.UpdateResponse, error)
func (*ReplicaSession) Get ¶
func (rs *ReplicaSession) Get(ctx context.Context, gpid *base.Gpid, key *base.Blob) (*rrdb.ReadResponse, error)
func (*ReplicaSession) GetScanner ¶
func (rs *ReplicaSession) GetScanner(ctx context.Context, gpid *base.Gpid, request *rrdb.GetScannerRequest) (*rrdb.ScanResponse, error)
func (*ReplicaSession) MultiDelete ¶
func (rs *ReplicaSession) MultiDelete(ctx context.Context, gpid *base.Gpid, request *rrdb.MultiRemoveRequest) (*rrdb.MultiRemoveResponse, error)
func (*ReplicaSession) MultiGet ¶
func (rs *ReplicaSession) MultiGet(ctx context.Context, gpid *base.Gpid, request *rrdb.MultiGetRequest) (*rrdb.MultiGetResponse, error)
func (*ReplicaSession) MultiSet ¶
func (rs *ReplicaSession) MultiSet(ctx context.Context, gpid *base.Gpid, request *rrdb.MultiPutRequest) (*rrdb.UpdateResponse, error)
func (*ReplicaSession) Scan ¶
func (rs *ReplicaSession) Scan(ctx context.Context, gpid *base.Gpid, request *rrdb.ScanRequest) (*rrdb.ScanResponse, error)
func (*ReplicaSession) SortKeyCount ¶
func (rs *ReplicaSession) SortKeyCount(ctx context.Context, gpid *base.Gpid, hashKey *base.Blob) (*rrdb.CountResponse, error)
type RpcRequestArgs ¶
a trait of the thrift-generated argument type (MetaQueryCfgArgs, RrdbPutArgs e.g.)
type RpcResponseResult ¶
a trait of the thrift-generated result type (MetaQueryCfgResult e.g.)