sync

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sync converts libgm events into store rows. The Pump is meant to be registered as an EventHandler on gm.Client. All persistence work runs inline on the libgm callback goroutine — SQLite writes against a local file are fast enough that this hasn't been measured to be a bottleneck. If it ever becomes one, swap Handle for a buffered-channel pump without changing the public interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConversationRow

func ConversationRow(c *gmproto.Conversation, platform string) (store.Conversation, bool)

ConversationRow converts a libgm conversation proto into the store row shape. Returns ok=false when the proto has no conversation ID. Exported so the RPC event broadcaster can emit the same shape the store persists.

func MessageRow

func MessageRow(w *libgm.WrappedMessage, platform string) (store.Message, bool)

MessageRow converts a wrapped libgm message into the store row shape. Returns ok=false when the proto has no message ID. Exported so the RPC event broadcaster can emit the same shape the store persists.

Types

type Pump

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

Pump owns the conversion of libgm events into store writes.

func New

func New(st *store.Store, logger zerolog.Logger) *Pump

New constructs a Pump that writes into st.

func (*Pump) Fatal

func (p *Pump) Fatal() <-chan error

Fatal returns a channel that receives terminal connection/auth errors. Long-running commands should select on this and exit non-zero so supervisors can restart or alert instead of silently idling after libgm gives up.

func (*Pump) Handle

func (p *Pump) Handle(evt any)

Handle is the entry point registered with gm.Client.Subscribe. It must not block; errors are logged but do not propagate.

func (*Pump) ImportContacts

func (p *Pump) ImportContacts(ctx context.Context, contacts []*gmproto.Contact) int

ImportContacts persists a full contact-list response from libgm.

func (*Pump) ImportMessages

func (p *Pump) ImportMessages(ctx context.Context, messages []*gmproto.Message) int

ImportMessages persists message-history rows fetched on demand. These are marked old so they don't advance the live-event freshness timestamp.

Jump to

Keyboard shortcuts

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