cloud

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cloud provides provider-neutral cloud key-value and file/snapshot storage across platforms: iCloud Key-Value Store and ubiquity containers on macOS and iOS, Google Play Games Saved Games on Android, and an isolated per-app in-memory store in nsgotest.

All operations are asynchronous and deliver their callbacks on the engine goroutine through core.Scope.Post; callbacks whose scope has been disposed never run. WatchChanges and OnConflict automatically clean up when cx is disposed.

Unavailable accounts, missing entitlements, or platforms without a cloud provider (such as Windows, Linux and the web) always fail with ErrUnavailable and never silently drop writes. On desktop stores such as Steam, Steam Auto-Cloud syncs core.Scope.DataDir directly without using this package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnavailable reports that cloud storage is unavailable on this platform, the user is not signed in, or the app lacks the required entitlements. Writes are never silently dropped.
	ErrUnavailable = core.ErrCloudUnavailable
	// ErrNotFound reports that a requested key or file does not exist.
	ErrNotFound = core.ErrCloudNotFound
	// ErrConflict reports that a cloud file or key has conflicting local and remote versions that must be resolved.
	ErrConflict = core.ErrCloudConflict
)

Sentinel errors returned by package cloud operations.

Functions

func Delete

func Delete(cx *core.Scope, key string, done func(err error))

Delete removes key from the cloud key-value store and delivers the result to done on the engine goroutine. Deleting a missing key succeeds when cloud storage is available; an unavailable store returns ErrUnavailable.

func DeleteFile

func DeleteFile(cx *core.Scope, name string, done func(err error))

DeleteFile removes the cloud file or snapshot named name and delivers the result to done on the engine goroutine. Deleting a missing file succeeds when cloud storage is available; an unavailable store returns ErrUnavailable.

func Get

func Get(cx *core.Scope, key string, done func(value []byte, err error))

Get reads the value for key from the cloud key-value store and delivers the result to done on the engine goroutine. It returns ErrNotFound if key does not exist and ErrUnavailable if cloud storage is unavailable.

func Keys

func Keys(cx *core.Scope, done func(keys []string, err error))

Keys lists all keys currently present in the cloud key-value store, sorted, and delivers them to done on the engine goroutine.

func ListFiles

func ListFiles(cx *core.Scope, done func(names []string, err error))

ListFiles lists all cloud files or snapshots currently stored, sorted, and delivers them to done on the engine goroutine.

func OnConflict

func OnConflict(cx *core.Scope, resolve func(Conflict)) (stop func())

OnConflict subscribes resolve to cloud version conflicts. Notifications are delivered on the engine goroutine and the subscription is automatically removed when cx is disposed or stop is called.

func ReadFile

func ReadFile(cx *core.Scope, name string, done func(data []byte, err error))

ReadFile reads the cloud file or snapshot named name and delivers its bytes to done on the engine goroutine. It returns ErrNotFound if missing, *ConflictError (unwrapping to ErrConflict) if unresolved conflicts exist, or ErrUnavailable if cloud storage is unavailable.

func Set

func Set(cx *core.Scope, key string, value []byte, done func(err error))

Set writes value for key in the cloud key-value store and delivers the result to done on the engine goroutine. It returns ErrUnavailable if cloud storage is unavailable and never silently drops writes.

func WatchChanges

func WatchChanges(cx *core.Scope, onChange func(ChangeEvent)) (stop func())

WatchChanges subscribes onChange to external cloud key-value and file changes. Notifications are delivered on the engine goroutine and the subscription is automatically removed when cx is disposed or stop is called.

func WriteFile

func WriteFile(cx *core.Scope, name string, data []byte, done func(err error))

WriteFile writes data to the cloud file or snapshot named name and delivers the result to done on the engine goroutine. It returns ErrUnavailable if cloud storage is unavailable and never silently drops writes.

Types

type ChangeEvent

type ChangeEvent = core.CloudChangeEvent

ChangeEvent describes keys and files changed externally in cloud storage.

type ChangeReason

type ChangeReason = core.CloudChangeReason

ChangeReason explains why an external cloud storage change arrived.

const (
	// ChangeServer reports data updated from another device or the server.
	ChangeServer ChangeReason = core.CloudChangeServer
	// ChangeInitialSync reports values downloaded on initial sync after install or sign-in.
	ChangeInitialSync ChangeReason = core.CloudChangeInitialSync
	// ChangeQuotaViolation reports that the cloud key-value store exceeded its quota.
	ChangeQuotaViolation ChangeReason = core.CloudChangeQuotaViolation
	// ChangeAccount reports that the signed-in cloud account changed.
	ChangeAccount ChangeReason = core.CloudChangeAccount
)

type Conflict

type Conflict = core.CloudConflict

Conflict describes a conflicting remote version of a cloud file or key along with a Resolve function that commits the winning bytes.

type ConflictError

type ConflictError = core.CloudConflictError

ConflictError describes a conflict between local and remote versions of a cloud key or file. It unwraps to ErrConflict.

Jump to

Keyboard shortcuts

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