Documentation
¶
Overview ¶
Package rpcstore implements the blob.Store that delegates to an underlying store via a JSON-RPC interface.
Index ¶
- type CAS
- type CASPutRequest
- type KeyRequest
- type ListReply
- type ListRequest
- type PutRequest
- type Service
- func (s Service) CASKey(ctx context.Context, req *CASPutRequest) ([]byte, error)
- func (s Service) CASPut(ctx context.Context, req *CASPutRequest) ([]byte, error)
- func (s Service) Delete(ctx context.Context, req *KeyRequest) error
- func (s Service) Get(ctx context.Context, req *KeyRequest) ([]byte, error)
- func (s Service) Len(ctx context.Context) (int64, error)
- func (s Service) List(ctx context.Context, req *ListRequest) (*ListReply, error)
- func (s Service) Methods() jrpc2.Assigner
- func (s Service) Put(ctx context.Context, req *PutRequest) error
- type ServiceOpts
- type Store
- func (s Store) Close(_ context.Context) error
- func (s Store) Delete(ctx context.Context, key string) error
- func (s Store) Get(ctx context.Context, key string) ([]byte, error)
- func (s Store) Len(ctx context.Context) (int64, error)
- func (s Store) List(ctx context.Context, start string, f func(string) error) error
- func (s Store) Put(ctx context.Context, opts blob.PutOptions) error
- func (s Store) ServerInfo(ctx context.Context) (*jrpc2.ServerInfo, error)
- type StoreOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CAS ¶
type CAS struct {
Store
}
CAS implements the blob.CAS interface by calling a JSON-RPC service.
type CASPutRequest ¶
type CASPutRequest struct { Data []byte `json:"data"` Prefix []byte `json:"prefix,omitempty"` Suffix []byte `json:"suffix,omitempty"` }
CASPutRequest is the request to the CASPut and CASGet methods.
type KeyRequest ¶
type KeyRequest struct {
Key []byte `json:"key"`
}
KeyRequest is the request to the Get, Delete, and Size methods.
type ListRequest ¶
ListRequest is the request to the List method.
type PutRequest ¶
type PutRequest struct { Key []byte `json:"key"` Data []byte `json:"data"` Replace bool `json:"replace"` }
PutRequest is the request to the Put method.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements a service that adapts RPC requests to a blob.Store.
All service instances export the following methods:
Method JSON Request and response messsages "get" {"key":"<storage-key"} "<blob-content>" "put" {"key":"<storage-key>","data":"<blob-content>","replace":bool} null "size" {"key":"<storage-key>"} <integer> "len": null <integer> "list": {"start":"<storage-key>","count":<integer>} {"keys":["<storage-key>",...],"next":"<storage-key>"}
If the store delegated to the service implements blob.CAS, the service will also export these additional methods:
"cas.put" {"data":"<blob-data>", "prefix":"...", "suffix":"..."} "<storage-key>" "cas.key" {"data":"<blob-data>", "prefix":"...", "suffix":"..."} "<storage-key>"
The data formats are:
<storage-key> : base-64 encoded string (key), example: "a2V5Zm9v" <blob-content> : base-64 encoded string (data), example: "ZGF0YWZvbw==" <integer> : JSON number with integer value, example: 532
func NewService ¶
func NewService(st blob.Store, opts *ServiceOpts) *Service
NewService constructs a Service that delegates to the given blob.Store.
func (Service) CASKey ¶
CASKey computes and returns the hash key for the specified data, if the service has a hash constructor installed.
func (Service) CASPut ¶
CASPut implements content-addressable storage if the service has a hash constructor installed.
func (Service) Delete ¶
func (s Service) Delete(ctx context.Context, req *KeyRequest) error
Delete handles the corresponding method of blob.Store.
type ServiceOpts ¶
type ServiceOpts struct{}
ServiceOpts provides optional settings for constructing a Service.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements the blob.Store interface by calling a JSON-RPC service.
func (Store) ServerInfo ¶
ServerInfo returns the JSON-RPC server status message.