storage

package
v0.0.0-...-1a40e3f Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStorage

func NewStorage() (Storage, DestroyFunc, error)

NewStorage initialize a new storage client

Types

type DestroyFunc

type DestroyFunc func()

DestroyFunc is to destroy any resources used by the storage returned in Create() together.

type EventType

type EventType string

EventType defines the type of watch event

const (
	// Created indicates an object is created
	Created EventType = "CREATED"
	// Deleted indicates an object is deleted
	Deleted EventType = "DELETED"
	// Updated indicates an object is updated
	Updated EventType = "UPDATED"
	// Error indicates an error occurs
	Error EventType = "ERROR"
)

type Storage

type Storage interface {
	Create(ctx context.Context, key string, data []byte, ttl int64) error
	Delete(ctx context.Context, key string) error
	Update(ctx context.Context, key string, data []byte) error
	Get(ctx context.Context, key string) ([]byte, error)
	List(ctx context.Context, key string) ([][]byte, error)
	Watch(ctx context.Context, key string, codec codec.Codec) (Watcher, error)
	Close() error
}

Storage defines the interface of a storage client

type WatchEvent

type WatchEvent struct {
	Type   EventType
	Object models.Object
}

WatchEvent defines events during a watch

type Watcher

type Watcher interface {
	Stop()
	ResultChan() <-chan WatchEvent
}

Watcher defines a watcher interface

Jump to

Keyboard shortcuts

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