chirpstore

package module
v0.0.0-...-834b540 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: BSD-3-Clause Imports: 10 Imported by: 2

README

chirpstore

GoDoc CI

Package chirpstore bridges the blob.Store interface over a Chirp v0 interface.

Documentation

Overview

Package chirpstore implements a Chirp v0 client and server exposing the blob.KV interface.

See https://github.com/creachadair/chirp for information about Chirp v0. See https://godoc.org/creachadair/ffs for information about blob.KV.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteRequest

type DeleteRequest = IDKeyRequest

type GetRequest

type GetRequest = IDKeyRequest

type HasRequest

type HasRequest struct {
	ID   int
	Keys []string
}

HasRequest is an encoding wrapper for the arguments of the Has method.

func (*HasRequest) Decode

func (s *HasRequest) Decode(data []byte) error

Decode parses data into the contents of s.

func (HasRequest) Encode

func (s HasRequest) Encode() []byte

Encode converts s into a binary string.

type IDKeyRequest

type IDKeyRequest struct {
	ID  int
	Key []byte
}

IDKeyRequest is a shared type for requests that take an ID and a key.

func (*IDKeyRequest) Decode

func (r *IDKeyRequest) Decode(data []byte) error

Decode data from binary format and replace the contents of g.

func (IDKeyRequest) Encode

func (r IDKeyRequest) Encode() []byte

Encode converts g into a binary string for request data.

type IDOnly

type IDOnly struct {
	ID int
}

IDOnly is a shared type for requests and responses that report only an ID.

func (*IDOnly) Decode

func (r *IDOnly) Decode(data []byte) error

Decode parses data into the contents of r.

func (IDOnly) Encode

func (r IDOnly) Encode() []byte

Encode converts r into a binary string.

type KV

type KV struct {
	// contains filtered or unexported fields
}

KV implements the blob.KV interface by calling a Chirp v0 peer.

func (KV) Delete

func (s KV) Delete(ctx context.Context, key string) error

Delete implements a method of blob.KV.

func (KV) Get

func (s KV) Get(ctx context.Context, key string) ([]byte, error)

Get implements a method of blob.KV.

func (KV) Has

func (s KV) Has(ctx context.Context, keys ...string) (blob.KeySet, error)

Has implements a method of blob.KV.

func (KV) Len

func (s KV) Len(ctx context.Context) (int64, error)

Len implements a method of blob.KV.

func (KV) List

func (s KV) List(ctx context.Context, start string) iter.Seq2[string, error]

List implements a method of blob.KV.

func (KV) Put

func (s KV) Put(ctx context.Context, opts blob.PutOptions) error

Put implements a method of blob.KV.

func (KV) Status

func (s KV) Status(ctx context.Context) ([]byte, error)

Status calls the status method of the store service.

type KeyspaceRequest

type KeyspaceRequest = IDKeyRequest

KeyspaceRequest is the encoding wrapper for a Keyspace request.

type KeyspaceResponse

type KeyspaceResponse = IDOnly

KeyspaceResponse is the encoding wrapper for a Keyspace response.

type LenRequest

type LenRequest = IDOnly

LenRequest is the encoding wrapper for a Len request.

type ListRequest

type ListRequest struct {
	ID    int
	Start []byte
	Count int
}

ListRequest is the an encoding wrapper for the arguments to the List method.

func (*ListRequest) Decode

func (r *ListRequest) Decode(data []byte) error

Decode data from binary format and replace the contents of r.

func (ListRequest) Encode

func (r ListRequest) Encode() []byte

Encode converts r into a binary string for request data.

type ListResponse

type ListResponse struct {
	Keys [][]byte
	Next []byte
}

ListResponse is the an encoding wrapper for the List method response.

func (*ListResponse) Decode

func (r *ListResponse) Decode(data []byte) error

Decode data from binary format and replaces the contents of r.

func (ListResponse) Encode

func (r ListResponse) Encode() []byte

Encode converts r into a binary string for response data.

type PutRequest

type PutRequest struct {
	ID      int
	Key     []byte
	Data    []byte
	Replace bool
}

PutRequest is an encoding wrapper for the arguments of the Put method.

func (*PutRequest) Decode

func (p *PutRequest) Decode(data []byte) error

Decode data from binary format and replace the contents of p.

func (PutRequest) Encode

func (p PutRequest) Encode() []byte

Encode converts p into a binary string for request data.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(st blob.Store, opts *ServiceOptions) *Service

NewService constructs a service that delegates to the given blob.KV.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, req *chirp.Request) ([]byte, error)

Delete handles the corresponding method of blob.KV.

func (*Service) Get

func (s *Service) Get(ctx context.Context, req *chirp.Request) ([]byte, error)

Get handles the corresponding method of blob.KV.

func (*Service) Has

func (s *Service) Has(ctx context.Context, req *chirp.Request) ([]byte, error)

Has handles the corresponding method of blob.KV.

func (*Service) KV

func (s *Service) KV(ctx context.Context, req *chirp.Request) ([]byte, error)

KV implements the eponymous method of the blob.Store interface. The client is returned an integer descriptor (ID) that must be presented in subsequent requests to identify which keyspace to affect.

func (*Service) Len

func (s *Service) Len(ctx context.Context, req *chirp.Request) ([]byte, error)

Len handles the corresponding method of blob.KV.

func (*Service) List

func (s *Service) List(ctx context.Context, req *chirp.Request) ([]byte, error)

List handles the corresponding method of blob.KV.

func (*Service) Put

func (s *Service) Put(ctx context.Context, req *chirp.Request) ([]byte, error)

Put handles the corresponding method of blob.KV.

func (*Service) Register

func (s *Service) Register(p *chirp.Peer)

Register adds method handlers to p for each of the applicable methods of s.

func (*Service) Status

func (s *Service) Status(ctx context.Context, req *chirp.Request) ([]byte, error)

Status returns a JSON blob of server metrics.

func (*Service) Sub

func (s *Service) Sub(ctx context.Context, req *chirp.Request) ([]byte, error)

Sub implements the eponymous method of the blob.Store interface. The client is returned an integer descriptor (ID) that must be presented in subsequent substore and keyspace requests to identify which store to affect.

type ServiceOptions

type ServiceOptions struct {
	// A prefix to prepend to all the method names exported by the service.
	Prefix string
}

ServiceOptions provides optional settings for constructing a Service.

type Store

type Store struct {
	*monitor.M[chirpStub, KV]
}

Store implements the blob.StoreCloser interface by delegating requests to a Chirp v0 peer. Store and KV operations are delegated to the remote peer.

func NewStore

func NewStore(peer *chirp.Peer, opts *StoreOptions) Store

NewStore constructs a Store that delegates through the given peer.

func (Store) Close

func (s Store) Close(context.Context) error

Close implements part of the blob.StoreCloser interface.

type StoreOptions

type StoreOptions struct {
	// A prefix to prepend to all the method names exported by the service.
	MethodPrefix string
}

StoreOptions provide optional settings for a Store. A nil is ready for use and provides default values.

type SubRequest

type SubRequest = IDKeyRequest

SubRequest is the encoding wrapper for a Sub request.

type SubResponse

type SubResponse = IDOnly

SubResponse is the encoding wrapper for a Sub response.

Jump to

Keyboard shortcuts

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