Documentation
¶
Index ¶
- Constants
- type DefaultService
- func (d *DefaultService) Connect() error
- func (d *DefaultService) DB() (*sql.DB, error)
- func (d *DefaultService) Disconnect() error
- func (d *DefaultService) GetLastSyncTokensUpdatedAt(ctx context.Context) (time.Time, error)
- func (d *DefaultService) UpdateLastSyncTokensUpdateAt(ctx context.Context, updatedAt time.Time) error
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 ¶
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
Click to show internal directories.
Click to hide internal directories.