github.com/christoph-karpowicz/db_mediator@v0.0.0-20210207102849-61a28a1071d8/internal/server/synch/operation.go (about) 1 package synch 2 3 import "encoding/json" 4 5 type operation interface { 6 toJSON() string 7 } 8 9 type updateOrIdleOperation struct { 10 IterationId string `json:"iterationId"` 11 Timestamp string `json:"timestamp"` 12 Operation string `json:"operation"` 13 SourceTableName string `json:"sourceTableName"` 14 SourceKeyName string `json:"sourceKeyName"` 15 SourceKeyValue interface{} `json:"sourceKeyValue"` 16 SourceColumnName string `json:"sourceColumnName"` 17 SourceColumnValue interface{} `json:"sourceColumnValue"` 18 TargetKeyName string `json:"targetKeyName"` 19 TargetKeyValue interface{} `json:"targetKeyValue"` 20 TargetColumnName string `json:"targetColumnName"` 21 TargetColumnValue interface{} `json:"targetColumnValue"` 22 TargetTableName string `json:"targetTableName"` 23 } 24 25 func (o *updateOrIdleOperation) toJSON() string { 26 operationsJSON, err := json.MarshalIndent(o, "", " ") 27 if err != nil { 28 panic(err) 29 } 30 return string(operationsJSON) 31 } 32 33 type insertOperation struct { 34 IterationId string `json:"iterationId"` 35 Timestamp string `json:"timestamp"` 36 Operation string `json:"operation"` 37 SourceTableName string `json:"sourceTableName"` 38 SourceKeyName string `json:"sourceKeyName"` 39 SourceKeyValue interface{} `json:"sourceKeyValue"` 40 SourceColumnName string `json:"sourceColumnName"` 41 TargetTableName string `json:"targetTableName"` 42 InsertedRow map[string]interface{} `json:"insertedRow"` 43 } 44 45 func (o *insertOperation) toJSON() string { 46 operationsJSON, err := json.MarshalIndent(o, "", " ") 47 if err != nil { 48 panic(err) 49 } 50 return string(operationsJSON) 51 }