in datahub/connector.go [376:408]
func marshalCreateMysqlConnector(ccr *CreateConnectorRequest) ([]byte, error) {
soConf, ok := ccr.Config.(SinkMysqlConfig)
if !ok {
return nil, NewInvalidParameterErrorWithMessage(fmt.Sprintf("config type error,your input config type is %s,should be SinkMysqlConfig", reflect.TypeOf(ccr.Config)))
}
// set default value
if soConf.TimestampUnit == "" {
soConf.TimestampUnit = ConnectorMicrosecond
}
// set default value
if soConf.TimestampUnit == "" {
soConf.TimestampUnit = ConnectorMicrosecond
}
ct := &struct {
Action string `json:"Action"`
Type ConnectorType `json:"Type"`
SinkStartTime int64 `json:"SinkStartTime"`
ColumnFields []string `json:"ColumnFields"`
ColumnNameMap map[string]string `json:"ColumnNameMap,omitempty"`
Config SinkMysqlConfig `json:"Config"`
}{
Action: "create",
Type: ccr.Type,
SinkStartTime: ccr.SinkStartTime,
ColumnFields: ccr.ColumnFields,
ColumnNameMap: ccr.ColumnNameMap,
Config: soConf,
}
return json.Marshal(ct)
}