cache

package
v0.0.0-...-9742f5a Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyRequest

func VerifyRequest(m *ccmsg.ClientCacheRequest) error

TODO: This should go somewhere non-cache-specific; initially, it was in ccmsg, but that created an import cycle.

N.B.: This does *not* consider anything about who has generated the batch signature; at present, it just checks that the data-carrying parts of the message are (indirectly) covered by that signature.

Types

type Application

type Application interface {
	common.StarterShutdowner
}

An Application is the top-level content publisher. It takes a configuration struct. Its children are the several protocol servers (that deal with clients, caches, and so forth).

func NewApplication

func NewApplication(l *logrus.Logger, c *Cache, db *sql.DB, conf *ConfigFile, kp *keypair.KeyPair, r *ledgerclient.Replicator) (Application, error)

type Cache

type Cache struct {
	PublicKey   ed25519.PublicKey
	Escrows     map[common.EscrowID]*Escrow
	Storage     *CacheStorage
	StoragePath string
	StartupTime time.Time
	Config      *ConfigFile
	// contains filtered or unexported fields
}

func NewCache

func NewCache(l *logrus.Logger, cf *ConfigFile, kp *keypair.KeyPair) (*Cache, error)

func (*Cache) AddEscrowToDatabase

func (c *Cache) AddEscrowToDatabase(ctx context.Context, escrow *Escrow) error

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) HandleRequest

func (c *Cache) HandleRequest(ctx context.Context, req *ccmsg.ClientCacheRequest) (*ccmsg.ClientCacheResponse, error)

func (*Cache) LoadFromDatabase

func (c *Cache) LoadFromDatabase(ctx context.Context) (int, error)

func (*Cache) OfferEscrow

type CacheStorage

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

func NewCacheStorage

func NewCacheStorage(l *logrus.Logger, badgerDirectory string) (*CacheStorage, error)

func (*CacheStorage) Close

func (s *CacheStorage) Close() error

func (*CacheStorage) DeleteData

func (s *CacheStorage) DeleteData(escrowID common.EscrowID, chunkID common.ChunkID) error

func (*CacheStorage) DeleteRawBytes

func (s *CacheStorage) DeleteRawBytes(key []byte) error

func (*CacheStorage) GetData

func (s *CacheStorage) GetData(escrowID common.EscrowID, chunkID common.ChunkID) ([]byte, error)

func (*CacheStorage) GetMetadata

func (s *CacheStorage) GetMetadata(escrowID common.EscrowID, objectID common.ObjectID) (*ccmsg.ObjectMetadata, error)

Returns (nil, nil) if the object does not exist; the error part of the rval is reserved for e.g. storage engine errors.

func (*CacheStorage) GetRawBytes

func (s *CacheStorage) GetRawBytes(key []byte) ([]byte, error)

func (*CacheStorage) PutData

func (s *CacheStorage) PutData(escrowID common.EscrowID, chunkID common.ChunkID, data []byte) error

func (*CacheStorage) PutMetadata

func (s *CacheStorage) PutMetadata(escrowID common.EscrowID, objectID common.ObjectID, m *ccmsg.ObjectMetadata) error

func (*CacheStorage) PutRawBytes

func (s *CacheStorage) PutRawBytes(key []byte, bytes []byte) error

type ConfigFile

type ConfigFile struct {
	ClientProtocolGrpcAddr string
	ClientProtocolHttpAddr string
	StatusAddr             string
	BootstrapAddr          string
	LedgerAddr             string

	BadgerDirectory string        `json:"badger_directory"`
	Database        string        `json:"database"`
	ContactUrl      string        `json:"contact_url"`
	MetricsEndpoint string        `json:"metrics_endpoint"`
	SyncInterval    time.Duration `json:"sync_interval"`
	Insecure        bool          `json:"insecure"`
}

type Escrow

type Escrow struct {
	Inner models.Escrow
}

func (*Escrow) Active

func (e *Escrow) Active() bool

func (*Escrow) InnerMasterKey

func (e *Escrow) InnerMasterKey() []byte

func (*Escrow) OuterMasterKey

func (e *Escrow) OuterMasterKey() []byte

func (*Escrow) PublisherAddr

func (e *Escrow) PublisherAddr() string

func (*Escrow) Slots

func (e *Escrow) Slots() uint64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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