sync

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package sync provides Gmail synchronization workflows.

Index

Constants

This section is empty.

Variables

View Source
var ErrHistoryExpired = errors.New("history expired - run full sync")

ErrHistoryExpired indicates that the Gmail history ID is too old and a full sync is required.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Query is an optional Gmail search query (e.g., "before:2020/01/01")
	Query string

	// NoResume forces a fresh sync even if a checkpoint exists
	NoResume bool

	// BatchSize is the number of messages to fetch in parallel (default: 10)
	BatchSize int

	// CheckpointInterval is how often to save progress (default: every 200 messages)
	CheckpointInterval int

	// AttachmentsDir is where to store attachments
	AttachmentsDir string

	// Limit caps the number of messages scanned per sync (0 = unlimited).
	// Enforced by truncating the message ID list before downloading content.
	// The API listing call (which returns lightweight IDs, not bodies) may
	// return more IDs than the limit; only the truncated set is fetched.
	Limit int
}

Options configures sync behavior.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns sensible defaults.

type Syncer

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

Syncer performs Gmail synchronization.

func New

func New(client gmail.API, store *store.Store, opts *Options) *Syncer

New creates a new Syncer.

func (*Syncer) Full

func (s *Syncer) Full(ctx context.Context, email string) (summary *gmail.SyncSummary, err error)

Full performs a full synchronization.

func (*Syncer) Incremental

func (s *Syncer) Incremental(ctx context.Context, email string) (summary *gmail.SyncSummary, err error)

Incremental performs an incremental sync using the Gmail History API. Falls back to full sync if history is too old (404 error).

func (*Syncer) WithLogger

func (s *Syncer) WithLogger(logger *slog.Logger) *Syncer

WithLogger sets the logger.

func (*Syncer) WithProgress

func (s *Syncer) WithProgress(p gmail.SyncProgress) *Syncer

WithProgress sets the progress reporter.

Jump to

Keyboard shortcuts

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