cloudsync

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvelopeSchemaVersion   = syncwire.EnvelopeSchemaVersion
	HeadSchemaVersion       = "pinax.cloud.head.v1"
	RevisionSchemaVersion   = "pinax.cloud.revision.v1"
	ManifestSchemaVersionV1 = syncwire.ManifestSchemaVersionV1
	ManifestSchemaVersionV2 = syncwire.ManifestSchemaVersionV2
	ManifestSchemaVersion   = syncwire.ManifestSchemaVersion
	ConflictSchemaVersion   = "pinax.cloud.conflict.v1"
)

Variables

View Source
var (
	ErrRevisionConflict = errors.New("revision_conflict")
	ErrObjectNotFound   = errors.New("object_not_found")
	ErrLockHeld         = errors.New("lock_held")
	ErrInvalidEnvelope  = errors.New("invalid_envelope")
)

Functions

This section is empty.

Types

type BatchCheckResult

type BatchCheckResult struct {
	MissingBlobIDs []string
	Present        []BlobFact
}

type BlobFact

type BlobFact struct {
	BlobID   string
	BlobHash string
	Size     int64
}

type CommitRequest

type CommitRequest struct {
	BaseRevision   string
	RevisionID     string
	ManifestBlobID string
	BlobIDs        []string
	ObjectRefs     []ObjectRef
	DeviceID       string
	RequestID      string
}

type CommitResult

type CommitResult struct {
	RevisionID     string
	RemoteWrite    bool
	ManifestBlobID string
}

type Conflict

type Conflict struct {
	SchemaVersion    string `json:"schema_version"`
	PathHash         string `json:"path_hash"`
	LocalBlobID      string `json:"local_blob_id"`
	RemoteBlobID     string `json:"remote_blob_id"`
	BaseRevisionID   string `json:"base_revision_id"`
	RemoteRevisionID string `json:"remote_revision_id"`
}

func (Conflict) Validate

func (c Conflict) Validate() error

type Envelope

type Envelope = syncwire.Envelope

Envelope is the syncwire envelope; cloudsync aliases it so the transport layer and the encryption helpers share one wire schema.

type Head struct {
	SchemaVersion   string `json:"schema_version"`
	VaultID         string `json:"vault_id"`
	CurrentRevision string `json:"current_revision"`
	ManifestBlobID  string `json:"manifest_blob_id"`
	UpdatedAt       string `json:"updated_at"`
	UpdatedByDevice string `json:"updated_by_device"`
}

type Layout

type Layout struct {
	Prefix      string
	WorkspaceID string
	VaultID     string
}

func (Layout) BlobKey

func (l Layout) BlobKey(blobID string) string

func (Layout) HeadKey

func (l Layout) HeadKey() string

func (Layout) LockKey

func (l Layout) LockKey() string

func (Layout) ManifestKey

func (l Layout) ManifestKey(blobID string) string

func (Layout) ProtocolKey

func (l Layout) ProtocolKey() string

func (Layout) RevisionKey

func (l Layout) RevisionKey(revisionID string) string

type Lock

type Lock struct {
	DeviceID  string    `json:"device_id"`
	RequestID string    `json:"request_id"`
	ExpiresAt time.Time `json:"expires_at"`
}

type Manifest

type Manifest = syncwire.Manifest

Manifest wire types are owned by syncwire; aliases keep cloudsync.* identifiers working with a single on-wire schema.

type ManifestDelete added in v0.1.3

type ManifestDelete = syncwire.ManifestDelete

Manifest wire types are owned by syncwire; aliases keep cloudsync.* identifiers working with a single on-wire schema.

type ManifestEntry

type ManifestEntry = syncwire.ManifestEntry

Manifest wire types are owned by syncwire; aliases keep cloudsync.* identifiers working with a single on-wire schema.

type MemoryTransport

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

func NewMemoryTransport

func NewMemoryTransport(layout Layout) *MemoryTransport

func (*MemoryTransport) AcquireLock

func (m *MemoryTransport) AcquireLock(_ context.Context, lock Lock, now time.Time) error

func (*MemoryTransport) BatchCheck

func (m *MemoryTransport) BatchCheck(_ context.Context, blobIDs []string) (BatchCheckResult, error)

func (*MemoryTransport) CommitRevision

func (m *MemoryTransport) CommitRevision(_ context.Context, req CommitRequest) (CommitResult, error)

func (*MemoryTransport) CurrentHead

func (m *MemoryTransport) CurrentHead(_ context.Context, vaultID string) (Head, error)

func (*MemoryTransport) GetBlob

func (m *MemoryTransport) GetBlob(_ context.Context, blobID string) (Envelope, error)

func (*MemoryTransport) GetManifest

func (m *MemoryTransport) GetManifest(_ context.Context, blobID string) (Envelope, error)

func (*MemoryTransport) PutBlob

func (m *MemoryTransport) PutBlob(_ context.Context, blobID string, envelope Envelope) error

func (*MemoryTransport) PutManifest

func (m *MemoryTransport) PutManifest(_ context.Context, blobID string, envelope Envelope) error

type ObjectRef

type ObjectRef struct {
	PathHash string
	BlobID   string
	BlobHash string
	Size     int64
	Deleted  bool
}

type ObjectStoreTransport

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

func NewObjectStoreTransport

func NewObjectStoreTransport(store remote.BlobStore, layout Layout) *ObjectStoreTransport

func (*ObjectStoreTransport) BatchCheck

func (t *ObjectStoreTransport) BatchCheck(ctx context.Context, blobIDs []string) (BatchCheckResult, error)

func (*ObjectStoreTransport) CommitRevision

func (t *ObjectStoreTransport) CommitRevision(ctx context.Context, req CommitRequest) (CommitResult, error)

func (*ObjectStoreTransport) CurrentHead

func (t *ObjectStoreTransport) CurrentHead(ctx context.Context, vaultID string) (Head, error)

func (*ObjectStoreTransport) GetBlob

func (t *ObjectStoreTransport) GetBlob(ctx context.Context, blobID string) (Envelope, error)

func (*ObjectStoreTransport) GetManifest

func (t *ObjectStoreTransport) GetManifest(ctx context.Context, blobID string) (Envelope, error)

func (*ObjectStoreTransport) PutBlob

func (t *ObjectStoreTransport) PutBlob(ctx context.Context, blobID string, envelope Envelope) error

func (*ObjectStoreTransport) PutManifest

func (t *ObjectStoreTransport) PutManifest(ctx context.Context, blobID string, envelope Envelope) error

type Revision

type Revision struct {
	SchemaVersion    string   `json:"schema_version"`
	RevisionID       string   `json:"revision_id"`
	ParentRevisionID string   `json:"parent_revision_id"`
	ManifestBlobID   string   `json:"manifest_blob_id"`
	BlobIDs          []string `json:"blob_ids"`
	CreatedAt        string   `json:"created_at"`
	CreatedByDevice  string   `json:"created_by_device"`
}

type Transport

type Transport interface {
	CurrentHead(ctx context.Context, vaultID string) (Head, error)
	BatchCheck(ctx context.Context, blobIDs []string) (BatchCheckResult, error)
	PutBlob(ctx context.Context, blobID string, envelope Envelope) error
	GetBlob(ctx context.Context, blobID string) (Envelope, error)
	PutManifest(ctx context.Context, blobID string, envelope Envelope) error
	GetManifest(ctx context.Context, blobID string) (Envelope, error)
	CommitRevision(ctx context.Context, req CommitRequest) (CommitResult, error)
}

Jump to

Keyboard shortcuts

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