sync

package
v0.0.0-...-78a7608 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	// Gmail: LastHistoryID; Outlook: DeltaLink (cursor)
	Cursor string
}

Checkpoint represents sync state for a provider

type InboxConfig

type InboxConfig struct {
	UserID   string
	InboxID  string
	Provider ProviderName
	UserJWT  string // JWT to fetch tokens from BetterAuth
}

InboxConfig config for user inbox sync

type MailProvider

type MailProvider interface {
	// InitialBackfill performs full import or deep backfill window
	InitialBackfill(ctx context.Context, user string, cp *Checkpoint, fn func(MessageMeta) error) (*Checkpoint, error)

	// IncrementalSync performs incremental sync from a checkpoint
	IncrementalSync(ctx context.Context, user string, cp Checkpoint, fn func(MessageMeta) error) (*Checkpoint, error)
}

MailProvider interface for provider-agnostic mail sync

type Manager

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

Manager manages multi-user sync workers

func NewManager

func NewManager(dataRoot string, authClient *auth.BetterAuthClient, publisher *natsjs.Publisher, providerFactory ProviderFactory) *Manager

NewManager creates sync manager

func (*Manager) GetRunningSyncs

func (m *Manager) GetRunningSyncs() []string

GetRunningSyncs returns list of currently running syncs

func (*Manager) IsRunning

func (m *Manager) IsRunning(userID, inboxID string, provider ProviderName) bool

IsRunning checks if sync is running for a user inbox

func (*Manager) StartSync

func (m *Manager) StartSync(ctx context.Context, config InboxConfig) error

StartSync starts syncing for user inbox

func (*Manager) StopAll

func (m *Manager) StopAll()

StopAll stops all running syncs

func (*Manager) StopSync

func (m *Manager) StopSync(userID, inboxID string, provider ProviderName) error

StopSync stops syncing for a user inbox

type MessageMeta

type MessageMeta struct {
	Provider       ProviderName
	UserID         string
	InboxID        string
	MessageID      string // provider ID (Gmail: Id, Outlook: id)
	ThreadID       string // provider thread/conversation id
	Subject        string
	Sender         string
	To             []string
	Cc             []string
	Bcc            []string
	Snippet        string
	ProviderLabels []string
	Headers        map[string]string
	MessageDate    time.Time
}

MessageMeta represents normalized email metadata across providers

type ProviderFactory

type ProviderFactory func(ctx context.Context, token *auth.Token, userID string, provider ProviderName) (MailProvider, error)

ProviderFactory creates MailProvider

type ProviderName

type ProviderName string

ProviderName represents email provider types

const (
	ProviderGoogle    ProviderName = "GOOGLE"
	ProviderMicrosoft ProviderName = "MICROSOFT"
)

type Runner

type Runner struct {
	DataRoot     string
	AuthClient   *auth.BetterAuthClient
	UserJWT      string
	Publisher    *natsjs.Publisher
	Provider     MailProvider
	ProviderName ProviderName
}

Runner orchestrates mail sync for user inbox

func (*Runner) RunInbox

func (r *Runner) RunInbox(ctx context.Context, userID, inboxID string) error

RunInbox runs continuous sync for a user inbox

Jump to

Keyboard shortcuts

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