remoteds

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PROTOCOL_V1 = "/cluster/remoteds/0.0.1"
	PREFIX      = "remoteds"
)
View Source
const AuthFailed = "unauthorized access denied"
View Source
const EOF = "query result finished"

Variables

This section is empty.

Functions

func DSQuery

func DSQuery(q Query) dsq.Query

func DefaultUserPrefix added in v0.0.7

func DefaultUserPrefix(req *Request, reply *ReplyMessage) bool

func NewStoreClient

func NewStoreClient(ctx context.Context, src host.Host, target peer.AddrInfo, pid protocol.ID, timeout int, token string) core.RemoteDataNodeClient

func NewStoreServer

func NewStoreServer(ctx context.Context, h host.Host, pid protocol.ID, ds, fds ds.Datastore, disableDelete bool, timeout int, interceptors ...Interceptor) core.DataNodeServer

func ReadQueryResultEntry

func ReadQueryResultEntry(s network.Stream, msg *QueryResultEntry, timeout int) error

func ReadReplyMsg

func ReadReplyMsg(s network.Stream, msg *ReplyMessage, timeout int) error

func ReadRequestMsg

func ReadRequestMsg(s network.Stream, msg *RequestMessage, timeout int) error

func WriteQueryResultEntry

func WriteQueryResultEntry(s network.Stream, msg *QueryResultEntry, timeout int) error

func WriteReplyMsg

func WriteReplyMsg(s network.Stream, msg *ReplyMessage, timeout int) error

func WriteRequstMsg

func WriteRequstMsg(s network.Stream, msg *RequestMessage, timeout int) error

Types

type Act

type Act uint8
const (
	ActPut Act = 1 + iota
	ActDelete
	ActGet
	ActGetSize
	ActHas
	ActQuery
	ActTouchFile
	ActFileInfo
	ActDeleteFile
	ActListFiles
)

type ErrCode

type ErrCode uint8
const (
	ErrNone ErrCode = iota
	ErrNotFound
	ErrAuthFailed
	ErrEOF

	ErrOthers = 100
)

type Interceptor added in v0.0.7

type Interceptor func(req *Request, reply *ReplyMessage) bool

Interceptor if return true, than send ReplyMessage to sender and skip the next processing

type Query

type Query struct {
	AccessToken string
	Prefix      string
	Limit       int64
	Offset      int64
	KeysOnly    bool
}

func P2PQuery

func P2PQuery(q dsq.Query) Query

func (*Query) MarshalCBOR

func (t *Query) MarshalCBOR(w io.Writer) error

func (*Query) UnmarshalCBOR

func (t *Query) UnmarshalCBOR(r io.Reader) error

type QueryResultEntry

type QueryResultEntry struct {
	Code  ErrCode
	Msg   string
	Key   string
	Value []byte
	Size  int64
}

func (*QueryResultEntry) MarshalCBOR

func (t *QueryResultEntry) MarshalCBOR(w io.Writer) error

func (*QueryResultEntry) UnmarshalCBOR

func (t *QueryResultEntry) UnmarshalCBOR(r io.Reader) error

type ReplyMessage

type ReplyMessage struct {
	Code   ErrCode
	Msg    string
	Value  []byte
	Size   int64
	Exists bool
}

func (*ReplyMessage) MarshalCBOR

func (t *ReplyMessage) MarshalCBOR(w io.Writer) error

func (*ReplyMessage) UnmarshalCBOR

func (t *ReplyMessage) UnmarshalCBOR(r io.Reader) error

type Request added in v0.0.7

type Request struct {
	*RequestMessage
	InnerFileKey    string
	InnerFilePrefix string
}

type RequestMessage

type RequestMessage struct {
	AccessToken string
	Key         string
	Value       []byte
	Query       Query
	Action      Act
}

func (*RequestMessage) MarshalCBOR

func (t *RequestMessage) MarshalCBOR(w io.Writer) error

func (*RequestMessage) UnmarshalCBOR

func (t *RequestMessage) UnmarshalCBOR(r io.Reader) error

Jump to

Keyboard shortcuts

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