dbsync

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("dbsync",
	fx.Provide(
		New,
	),
)

Functions

This section is empty.

Types

type DBSyncConfig

type DBSyncConfig struct {
	WatchConfig bool `default:"true" yaml:"watchConfig"`

	StateFile string `default:"dbsync.state.yaml" yaml:"stateFile"`

	Destination DBSyncDestination `yaml:"destination"`
	Source      DBSyncSource      `yaml:"source"`

	Tables DBSyncSourceTables `yaml:"tables"`
}

func (*DBSyncConfig) GetSyncInterval

func (c *DBSyncConfig) GetSyncInterval(table DBSyncTableSyncInterval) time.Duration

type DBSyncDestination

type DBSyncDestination struct {
	URL      string `yaml:"url"`
	Token    string `yaml:"token"`
	Insecure bool   `yaml:"insecure"`

	SyncInterval time.Duration `default:"5s" yaml:"syncInterval"`
}

type DBSyncSource

type DBSyncSource struct {
	// Refer to https://github.com/go-sql-driver/mysql#dsn-data-source-name for details
	DSN string `yaml:"dsn"`
}

type DBSyncSourceTables

type DBSyncSourceTables struct {
	Jobs      DBSyncTable `yaml:"jobs"`
	JobGrades DBSyncTable `yaml:"jobGrades"`
	Licenses  DBSyncTable `yaml:"licenses"`

	Users        UsersDBSyncTable `yaml:"users"`
	UserLicenses DBSyncTable      `yaml:"userLicenses"`
	Vehicles     DBSyncTable      `yaml:"vehicles"`
}

type DBSyncState

type DBSyncState struct {
	Jobs      *TableSyncState `yaml:"jobs"`
	JobGrades *TableSyncState `yaml:"jobGrades"`
	Licenses  *TableSyncState `yaml:"licenses"`

	Users         *TableSyncState `yaml:"users"`
	OwnedVehicles *TableSyncState `yaml:"ownedVehicles"`
	// contains filtered or unexported fields
}

func NewDBSyncState

func NewDBSyncState(logger *zap.Logger, filepath string) *DBSyncState

func (*DBSyncState) Load

func (s *DBSyncState) Load() error

func (*DBSyncState) Save

func (s *DBSyncState) Save() error

type DBSyncTable

type DBSyncTable struct {
	Enabled           bool           `yaml:"enabled"`
	UpdatedTimeColumn *string        `yaml:"updatedTimeColumn"`
	Query             string         `yaml:"query"`
	SyncInterval      *time.Duration `yaml:"syncInterval"`
}

func (*DBSyncTable) GetSyncInterval

func (c *DBSyncTable) GetSyncInterval() *time.Duration

type DBSyncTableSyncInterval

type DBSyncTableSyncInterval interface {
	GetSyncInterval() *time.Duration
}

type DateOfBirthNormalizer

type DateOfBirthNormalizer struct {
	Formats      []string `yaml:"formats"`
	OutputFormat string   `default:"" yaml:"output"`
}

type Params

type Params struct {
	fx.In

	LC         fx.Lifecycle
	Shutdowner fx.Shutdowner

	Logger *zap.Logger
	Config *config.Config
}

type Sync

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

func New

func New(p Params) (*Sync, error)

func (*Sync) Run

func (s *Sync) Run(ctx context.Context)

func (*Sync) RunStream

func (s *Sync) RunStream(ctx context.Context)

type TableSyncState

type TableSyncState struct {
	LastCheck *time.Time `yaml:"lastCheck"`
	Offset    uint64     `yaml:"offset"`
	LastID    *string    `yaml:"lastId"`
	SyncedUp  bool       `yaml:"syncedUp"`
	// contains filtered or unexported fields
}

func (*TableSyncState) Set

func (s *TableSyncState) Set(offset uint64, lastId *string)

type UsersDBSyncTable

type UsersDBSyncTable struct {
	DBSyncTable `yaml:",inline" mapstructure:",squash"`

	SplitName    bool                  `default:"false" yaml:"splitName"`
	DateOfBirth  DateOfBirthNormalizer `yaml:"dateOfBirth"`
	ValueMapping *UsersValueMappings   `yaml:"valueMapping"`
}

type UsersValueMappings

type UsersValueMappings struct {
	Sex *ValueMapping `yaml:"sex"`
}

type ValueMapping

type ValueMapping struct {
	Fallback *string           `yaml:"fallback"`
	Values   map[string]string `yaml:"values"`
}

func (*ValueMapping) IsEmpty

func (c *ValueMapping) IsEmpty() bool

func (*ValueMapping) Process

func (c *ValueMapping) Process(input *string)

Jump to

Keyboard shortcuts

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