Documentation
¶
Overview ¶
Package pods saves and loads named, versioned whole-emulator snapshots ("pods") to a local directory or an S3-compatible bucket.
Index ¶
- Constants
- Variables
- func MergeScoped(current, incoming []byte) ([]byte, bool, error)
- func ValidName(name string) bool
- type BlobStore
- type DirStore
- type Manifest
- type S3Config
- type S3Store
- type Service
- func (s *Service) Delete(ctx context.Context, name string, version int) error
- func (s *Service) Inspect(ctx context.Context, name string, version int) (Manifest, error)
- func (s *Service) List(ctx context.Context) ([]Summary, error)
- func (s *Service) Load(ctx context.Context, name string, version int, services []string) (Manifest, map[string][]byte, error)
- func (s *Service) Save(ctx context.Context, name, message string, snaps map[string][]byte) (Manifest, error)
- func (s *Service) Versions(ctx context.Context, name string) ([]Manifest, error)
- type Summary
Constants ¶
const Format = "gopherstack-pod/v1"
Format identifies the pod archive layout.
Variables ¶
var ( // ErrInvalidName is returned for pod names that are unsafe as storage keys. ErrInvalidName = errors.New("invalid pod name") // ErrCorrupt is returned when a stored pod archive cannot be read. ErrCorrupt = errors.New("pod archive is corrupt") // ErrBucketRequired is returned when an S3 store is configured without a bucket. ErrBucketRequired = errors.New("pods: s3 bucket is required") )
var ErrNotFound = errors.New("pod not found")
ErrNotFound is returned when a pod, version or blob does not exist.
Functions ¶
func MergeScoped ¶
MergeScoped merges the incoming service snapshot into current per account/region: records in an account/region present in incoming replace current's records for that scope, other scopes in current are kept. scoped is false when incoming has no account/region records; the caller must then replace the whole service state.
Types ¶
type BlobStore ¶
type BlobStore interface {
Put(ctx context.Context, key string, data []byte) error
Get(ctx context.Context, key string) ([]byte, error)
// List returns every key that starts with prefix, sorted.
List(ctx context.Context, prefix string) ([]string, error)
Delete(ctx context.Context, key string) error
}
BlobStore is the minimal object storage pods need. Keys use "/" separators.
type DirStore ¶
type DirStore struct {
// contains filtered or unexported fields
}
DirStore stores blobs as files under a root directory.
func NewDirStore ¶
NewDirStore returns a DirStore rooted at dir, creating it if needed.
type Manifest ¶
type Manifest struct {
CreatedAt time.Time `json:"createdAt"`
Name string `json:"name"`
Format string `json:"format"`
Message string `json:"message,omitempty"`
Services []string `json:"services"`
Version int `json:"version"`
Size int64 `json:"size"`
}
Manifest describes one saved pod version.
type S3Config ¶
type S3Config struct {
Bucket string
Prefix string
Endpoint string
Region string
AccessKey string
SecretKey string
PathStyle bool
}
S3Config configures an S3-compatible remote. Endpoint may point at real AWS S3 (leave empty), another S3-compatible server, or Gopherstack itself.
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
S3Store stores blobs as S3 objects under Prefix.
func NewS3Store ¶
NewS3Store builds an S3-backed BlobStore. Without explicit keys the default AWS credential chain is used.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements pod operations over a BlobStore.
func (*Service) Load ¶
func (s *Service) Load( ctx context.Context, name string, version int, services []string, ) (Manifest, map[string][]byte, error)
Load returns the manifest and per-service snapshots of a version (0 = latest). When services is non-empty only those services are returned.