mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-03 08:24:28 +02:00
remove streamType field
This commit is contained in:
@@ -664,7 +664,8 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||
Type: "array",
|
||||
Items: &apiextv1.JSONSchemaPropsOrArray{
|
||||
Schema: &apiextv1.JSONSchemaProps{
|
||||
Type: "object",
|
||||
Type: "object",
|
||||
Required: []string{"database", "tables"},
|
||||
Properties: map[string]apiextv1.JSONSchemaProps{
|
||||
"batchSize": {
|
||||
Type: "integer",
|
||||
@@ -688,17 +689,6 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||
},
|
||||
},
|
||||
},
|
||||
"streamType": {
|
||||
Type: "string",
|
||||
Enum: []apiextv1.JSON{
|
||||
{
|
||||
Raw: []byte(`"nakadi"`),
|
||||
},
|
||||
{
|
||||
Raw: []byte(`"wal"`),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -229,9 +229,8 @@ type ConnectionPooler struct {
|
||||
}
|
||||
|
||||
type Stream struct {
|
||||
StreamType string `json:"streamType,omitempty"`
|
||||
Database string `json:"database,omitempty"`
|
||||
Tables map[string]string `json:"tables,omitempty"`
|
||||
Filter map[string]string `json:"filter,omitempty"`
|
||||
BatchSize uint32 `json:"batchSize,omitempty"`
|
||||
Database string `json:"database"`
|
||||
Tables map[string]string `json:"tables"`
|
||||
Filter map[string]string `json:"filter,omitempty"`
|
||||
BatchSize uint32 `json:"batchSize,omitempty"`
|
||||
}
|
||||
|
||||
@@ -40,12 +40,8 @@ type EventStream struct {
|
||||
|
||||
// EventStreamFlow defines the flow characteristics of the event stream
|
||||
type EventStreamFlow struct {
|
||||
Type string `json:"type"`
|
||||
DataTypeColumn string `json:"dataTypeColumn,omitempty"`
|
||||
DataOpColumn string `json:"dataOpColumn,omitempty"`
|
||||
MetadataColumn string `json:"metadataColumn,omitempty"`
|
||||
DataColumn string `json:"dataColumn,omitempty"`
|
||||
PayloadColumn string `json:"payloadColumn,omitempty"`
|
||||
Type string `json:"type"`
|
||||
PayloadColumn string `json:"payloadColumn,omitempty" defaults:"payload"`
|
||||
}
|
||||
|
||||
// EventStreamSink defines the target of the event stream
|
||||
@@ -67,7 +63,7 @@ type EventStreamSource struct {
|
||||
// EventStreamTable defines the name and ID column to be used for streaming
|
||||
type EventStreamTable struct {
|
||||
Name string `json:"name"`
|
||||
IDColumn string `json:"idColumn,omitempty"`
|
||||
IDColumn string `json:"idColumn,omitempty" defaults:"id"`
|
||||
}
|
||||
|
||||
// Connection to be used for allowing the FES operator to connect to a database
|
||||
|
||||
+6
-20
@@ -150,23 +150,9 @@ func (c *Cluster) getEventStreamSource(stream acidv1.Stream, table, eventType st
|
||||
}
|
||||
|
||||
func getEventStreamFlow(stream acidv1.Stream) zalandov1alpha1.EventStreamFlow {
|
||||
switch stream.StreamType {
|
||||
case "nakadi":
|
||||
return zalandov1alpha1.EventStreamFlow{
|
||||
Type: constants.EventStreamFlowPgNakadiType,
|
||||
DataTypeColumn: constants.EventStreamFlowDataTypeColumn,
|
||||
DataOpColumn: constants.EventStreamFlowDataOpColumn,
|
||||
MetadataColumn: constants.EventStreamFlowMetadataColumn,
|
||||
DataColumn: constants.EventStreamFlowDataColumn,
|
||||
}
|
||||
case "wal":
|
||||
return zalandov1alpha1.EventStreamFlow{
|
||||
Type: constants.EventStreamFlowPgGenericType,
|
||||
PayloadColumn: constants.EventStreamFlowPayloadColumn,
|
||||
}
|
||||
return zalandov1alpha1.EventStreamFlow{
|
||||
Type: constants.EventStreamFlowPgGenericType,
|
||||
}
|
||||
|
||||
return zalandov1alpha1.EventStreamFlow{}
|
||||
}
|
||||
|
||||
func getEventStreamSink(stream acidv1.Stream, eventType string) zalandov1alpha1.EventStreamSink {
|
||||
@@ -190,8 +176,7 @@ func getTableSchema(fullTableName string) (tableName, schemaName string) {
|
||||
|
||||
func getOutboxTable(tableName, eventType string) zalandov1alpha1.EventStreamTable {
|
||||
return zalandov1alpha1.EventStreamTable{
|
||||
Name: outboxTableNameTemplate.Format("table", tableName, "eventtype", eventType),
|
||||
IDColumn: "id",
|
||||
Name: outboxTableNameTemplate.Format("table", tableName, "eventtype", eventType),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,15 +221,16 @@ func (c *Cluster) syncStreams() error {
|
||||
c.logger.Infof("event streams do not exist, create it")
|
||||
err := c.createStreams()
|
||||
if err != nil {
|
||||
return fmt.Errorf("event stream creation failed: %v", err)
|
||||
return fmt.Errorf("event streams creation failed: %v", err)
|
||||
}
|
||||
} else {
|
||||
desiredStreams := c.generateFabricEventStream()
|
||||
if !reflect.DeepEqual(effectiveStreams.Spec, desiredStreams.Spec) {
|
||||
c.logger.Debug("updating event streams")
|
||||
desiredStreams.ObjectMeta.ResourceVersion = effectiveStreams.ObjectMeta.ResourceVersion
|
||||
err = c.updateStreams(desiredStreams)
|
||||
if err != nil {
|
||||
return fmt.Errorf("event stream update failed: %v", err)
|
||||
return fmt.Errorf("event streams update failed: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,16 +47,7 @@ var (
|
||||
},
|
||||
Streams: []acidv1.Stream{
|
||||
{
|
||||
StreamType: "nakadi",
|
||||
Database: "foo",
|
||||
Tables: map[string]string{
|
||||
"bar": "stream_type_a",
|
||||
},
|
||||
BatchSize: uint32(100),
|
||||
},
|
||||
{
|
||||
StreamType: "wal",
|
||||
Database: "foo",
|
||||
Database: "foo",
|
||||
Tables: map[string]string{
|
||||
"bar": "stream_type_a",
|
||||
},
|
||||
@@ -132,8 +123,7 @@ func TestUpdateFabricEventStream(t *testing.T) {
|
||||
var pgSpec acidv1.PostgresSpec
|
||||
pgSpec.Streams = []acidv1.Stream{
|
||||
{
|
||||
StreamType: "nakadi",
|
||||
Database: "foo",
|
||||
Database: "foo",
|
||||
Tables: map[string]string{
|
||||
"bar": "stream_type_b",
|
||||
},
|
||||
|
||||
@@ -2,15 +2,9 @@ package constants
|
||||
|
||||
// PostgreSQL specific constants
|
||||
const (
|
||||
EventStreamSourcePGType = "PostgresLogicalReplication"
|
||||
EventStreamSourceSlotPrefix = "fes"
|
||||
EventStreamSourceAuthType = "DatabaseAuthenticationSecret"
|
||||
EventStreamFlowPgNakadiType = "PostgresWalToNakadiDataEvent"
|
||||
EventStreamFlowPgGenericType = "PostgresWalToGenericNakadiEvent"
|
||||
EventStreamFlowDataTypeColumn = "data_type"
|
||||
EventStreamFlowDataOpColumn = "data_op"
|
||||
EventStreamFlowMetadataColumn = "metadata"
|
||||
EventStreamFlowDataColumn = "data"
|
||||
EventStreamFlowPayloadColumn = "payload"
|
||||
EventStreamSinkNakadiType = "Nakadi"
|
||||
EventStreamSourcePGType = "PostgresLogicalReplication"
|
||||
EventStreamSourceSlotPrefix = "fes"
|
||||
EventStreamSourceAuthType = "DatabaseAuthenticationSecret"
|
||||
EventStreamFlowPgGenericType = "PostgresWalToGenericNakadiEvent"
|
||||
EventStreamSinkNakadiType = "Nakadi"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user