upload

package
v1.22.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package upload handles uploading local changes to the backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchCompletedHook added in v1.22.1

type BatchCompletedHook func(ctx context.Context) error

BatchCompletedHook is called after a batch is atomically completed in SQLite. Errors are logged and do not fail the upload cycle.

type Emitter

type Emitter func(Event)

Emitter is a function that handlers use to emit events.

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event is the interface for all upload events. Handlers can define their own event types that implement this interface.

type Handler

type Handler interface {
	Handle(ctx context.Context, entry *db.CrudEntry, emit Emitter) error
}

Handler processes CRUD entries for a specific table.

type Option added in v1.22.1

type Option func(*uploader)

Option configures uploader behavior.

func WithBatchCompletedHook added in v1.22.1

func WithBatchCompletedHook(hook BatchCompletedHook) Option

WithBatchCompletedHook installs a callback invoked after each successful batch completion.

type RecoveredEvent

type RecoveredEvent struct {
	StalledFor time.Duration
}

RecoveredEvent is emitted when upload recovers from a stalled state.

type StalledEvent

type StalledEvent struct {
	Error      error
	Table      sqlite.Table
	RowID      string
	StalledFor time.Duration
}

StalledEvent is emitted when upload is blocked on a failing entry.

type SyncingEvent

type SyncingEvent struct {
	ProcessedCount int
}

SyncingEvent is emitted when entries are being processed.

type TokenRefresher

type TokenRefresher interface {
	GetAccessToken(ctx context.Context) (string, error)
}

TokenRefresher provides access tokens for authentication.

type Uploader

type Uploader interface {
	Run(ctx context.Context) error
	Events() <-chan Event
}

Uploader watches the CRUD queue and uploads changes to the backend.

func New

func New(
	database sqlite.DB,
	client psapi.Client,
	tokenRefresher TokenRefresher,
	conversations api.Conversations,
	messages api.Messages,
	services api.Services,
	policies api.Policies,
	scope log.Scope,
	opts ...Option,
) Uploader

New creates a new uploader.

Jump to

Keyboard shortcuts

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