Documentation ¶
Overview ¶
Package synch handles all data sychronization.
Index ¶
- Constants
- func FindSynchType(sType string) (synchType, error)
- type Link
- type Mapping
- type Pair
- type Result
- type Synch
- func (s *Synch) Flush() *Result
- func (s *Synch) GetConfig() *cfg.SynchConfig
- func (s *Synch) GetIteration() *iteration
- func (s *Synch) GetNodes() map[string]*node
- func (s *Synch) GetRawMappings() []map[string]string
- func (s *Synch) GetType() synchType
- func (s *Synch) Init(DBMap map[string]*db.Database, stype string) string
- func (s *Synch) IsInitial() bool
- func (s *Synch) IsRunning() bool
- func (s *Synch) IsSimulation() bool
- func (s *Synch) Reset()
- func (s *Synch) Run()
- func (s *Synch) SetInitial(ini bool)
- func (s *Synch) SetSimulation(sim bool)
- func (s *Synch) Stop()
- type Synchronizer
- type Synchs
Constants ¶
const ( SIMULATION_DIR = "./simulation/" LOGS_DIR = "./log/" )
const ( ONE_OFF synchType = iota + 1 ONGOING )
Variables ¶
This section is empty.
Functions ¶
func FindSynchType ¶
FindSynchType returns a synch type based on a string.
Types ¶
type Link ¶
type Link struct { Cmd string // contains filtered or unexported fields }
Link represents a single link in the config file like: [example_node1.example_column1 WHERE ...] TO [example_node2.example_column2 WHERE ...]
type Mapping ¶
type Mapping struct {
// contains filtered or unexported fields
}
Mapping represents a single mapping in the config file like: example_node1.example_column1 TO example_node2.example_column2
type Pair ¶
type Pair struct { Link *Link // contains filtered or unexported fields }
Pair represents a connection between two records, that are going to be synchronized. Can be complete or incomplete, where incomplete means that there's only a source record and the target record will have to be created if the synchronization is to be carried out. When a pair is incomplete, a target record will be created only if the parent mapping is configured to DO INSERTs.
func (Pair) Synchronize ¶
Synchronize carries out the synchronization of the two records. Updates if this pair is complete (has both the source and the target) and inserts if a target record has to be created.
type Result ¶
type Result struct { Message string `json:"message"` Operations []operation `json:"operations"` // contains filtered or unexported fields }
func (*Result) OperationsToJSON ¶
type Synch ¶
type Synch struct { Links []*Link // contains filtered or unexported fields }
Synch represents an individual synchronzation configration. It holds all configuration from an .yaml file, raw and parsed.
func (*Synch) GetConfig ¶
func (s *Synch) GetConfig() *cfg.SynchConfig
GetConfig returns the synch config struct.
func (*Synch) GetIteration ¶
func (s *Synch) GetIteration() *iteration
GetIteration returns the synch's current iteration.
func (*Synch) GetRawMappings ¶
func (*Synch) Init ¶
Init prepares the synchronization by fetching all necessary data and parsing it.
func (*Synch) IsSimulation ¶
func (*Synch) Reset ¶
func (s *Synch) Reset()
Reset clears data preparing the Synch for the next run.
func (*Synch) SetInitial ¶
SetInitial sets the initial struct field indicating whether it's the first run of the synch.
func (*Synch) SetSimulation ¶
type Synchronizer ¶
type Synchronizer interface { GetConfig() *cfg.SynchConfig GetIteration() *iteration GetNodes() map[string]*node GetRawMappings() []map[string]string GetType() synchType IsSimulation() bool Run() }
Synchronizer is implemented by structs that do the actual synchronization actions.