Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoSyncState = fmt.Errorf("no sync state found")
ErrNoSyncState is returned when no sync state is found in the database.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { StripeAPIKey string // ExcludedFields is a list of fields that should be excluded from the sync. ExcludedFields []string Postgres PostgresConfig }
Config is the configuration for the StripeSync handle.
type PostgresConfig ¶
type PostgresConfig struct { Host string Port int User string Password string DBName string SSLMode string }
PostgresConfig is the configuration for the connection to the Postgres database.
func (PostgresConfig) StoreConfig ¶
func (pc PostgresConfig) StoreConfig() postgres.Config
StoreConfig returns the PostgresConfig as the postgres package expects it.
type StripeSync ¶
type StripeSync struct {
// contains filtered or unexported fields
}
StripeSync is a struct that holds the common global state for all operations.
func (*StripeSync) GetCurrentSyncState ¶
func (o *StripeSync) GetCurrentSyncState(ctx context.Context) (SyncState, error)
GetCurrentSyncState returns the current sync state from the database.
func (*StripeSync) InitialLoad ¶
func (o *StripeSync) InitialLoad(ctx context.Context, purge bool) error
InitialLoad loads all data from Stripe into the database. This is generally necessary if you have not synced in the last 30 days, as Stripe only keeps events for 30 days. If purge is true, it will delete all existing data from the database before loading.
func (StripeSync) MigrateDB ¶
func (o StripeSync) MigrateDB(ctx context.Context) error
MigrateDB automatically migrates the database schema to the latest version. This is useful for setting up the database schema for the first time.
This only happens the happy path, if there are any errors, the user will need to fix them manually.
func (*StripeSync) SyncEvents ¶
func (o *StripeSync) SyncEvents(ctx context.Context) error
SyncEvents syncs all events from stripe (which are up to 30 days old) to the database.
type SyncState ¶
type SyncState struct { // LastEvent is the timestamp of the last event that was synced in unix time. LastEvent int64 // contains filtered or unexported fields }
SyncState contains information about previous sync operations.
func (SyncState) LastEventTime ¶
LastEventTime returns the time of the last event that was synced.
func (SyncState) MayBeOutdated ¶
MayBeOutdated returns true if the sync state is older than 30 days.