sync

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateSyncTokensTableQuery is the SQL query to create the sync_tokens table
	CreateSyncTokensTableQuery = `
CREATE TABLE IF NOT EXISTS sync_tokens (id INTEGER PRIMARY KEY AUTOINCREMENT, updated_at DATETIME NOT NULL);
`

	// UpdateLastSyncTokensUpdatedAtQuery is the SQL query to insert a new sync tokens record
	UpdateLastSyncTokensUpdatedAtQuery = `
INSERT INTO sync_tokens (updated_at) VALUES (?);
`

	// GetLastSyncTokensUpdatedAtQuery is the SQL query to get the last sync tokens record
	GetLastSyncTokensUpdatedAtQuery = `
SELECT updated_at FROM sync_tokens ORDER BY updated_at DESC LIMIT 1;
`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultService

type DefaultService struct {
	godatabasessql.Handler
	// contains filtered or unexported fields
}

DefaultService is the default implementation of the Service interface

func NewDefaultService

func NewDefaultService(
	handler godatabasessql.Handler,
	logger *slog.Logger,
) (*DefaultService, error)

NewDefaultService creates a new DefaultService

Parameters:

  • handler: the SQL connection handler
  • logger: the logger (optional, can be nil)

Returns:

  • *DefaultService: the DefaultService instance
  • error: an error if the data source or driver name is empty

func (*DefaultService) Connect

func (d *DefaultService) Connect() error

Connect opens the database connection

Returns:

  • error: an error if the connection could not be opened

func (*DefaultService) DB

func (d *DefaultService) DB() (*sql.DB, error)

DB is a helper function to get the database connection

Returns:

  • *sql.DB: the database connection

func (*DefaultService) Disconnect

func (d *DefaultService) Disconnect() error

Disconnect closes the database connection

Returns:

  • error: an error if the connection could not be closed

func (*DefaultService) GetLastSyncTokensUpdatedAt

func (d *DefaultService) GetLastSyncTokensUpdatedAt(ctx context.Context) (
	time.Time,
	error,
)

GetLastSyncTokensUpdatedAt gets the last sync tokens updated at timestamp

Parameters:

  • ctx: the context

Returns:

  • time.Time: the last sync tokens updated at timestamp
  • error: an error if the timestamp could not be retrieved

func (*DefaultService) UpdateLastSyncTokensUpdateAt

func (d *DefaultService) UpdateLastSyncTokensUpdateAt(
	ctx context.Context,
	updatedAt time.Time,
) error

UpdateLastSyncTokensUpdateAt updates the last sync tokens updated at timestamp

Parameters:

  • ctx: the context
  • updatedAt: the new timestamp

Returns:

  • error: an error if the timestamp could not be updated

Jump to

Keyboard shortcuts

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