re-add 3rd type, remove callHome flow

This commit is contained in:
Felix Kunde 2021-08-27 13:00:38 +02:00
parent 7a84c0852c
commit d2addd3b17
9 changed files with 68 additions and 25 deletions

View File

@ -490,6 +490,8 @@ spec:
type: string type: string
sqsArn: sqsArn:
type: string type: string
sqsFifo:
type: boolean
tables: tables:
type: object type: object
additionalProperties: additionalProperties:
@ -499,6 +501,7 @@ spec:
enum: enum:
- "nakadi" - "nakadi"
- "sqs" - "sqs"
- "wal"
teamId: teamId:
type: string type: string
tls: tls:

View File

@ -198,10 +198,17 @@ spec:
# tables: # tables:
# ta: event_type_a # ta: event_type_a
# tb: event_type_b # tb: event_type_b
# - type: wal
# batchSize: 100
# database: foo
# tables:
# public.tx: event_type_a
# public.ty: event_type_b
# - type: sqs # - type: sqs
# database: foo # database: foo
# tables: # tables:
# ta: "" # ta: ""
# tb: "" # tb: ""
# sqsArn: arn:aws:sqs:eu-central-1:111122223333 # sqsArn: arn:aws:sqs:eu-central-1:111122223333
# sqsFifo: true
# queueName: foo-queue # queueName: foo-queue

View File

@ -486,6 +486,8 @@ spec:
type: string type: string
sqsArn: sqsArn:
type: string type: string
sqsFifo:
type: boolean
tables: tables:
type: object type: object
additionalProperties: additionalProperties:
@ -495,6 +497,7 @@ spec:
enum: enum:
- "nakadi" - "nakadi"
- "sqs" - "sqs"
- "wal"
teamId: teamId:
type: string type: string
tls: tls:

View File

@ -684,6 +684,9 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
"sqsArn": { "sqsArn": {
Type: "string", Type: "string",
}, },
"sqsFifo": {
Type: "boolean",
},
"tables": { "tables": {
Type: "object", Type: "object",
AdditionalProperties: &apiextv1.JSONSchemaPropsOrBool{ AdditionalProperties: &apiextv1.JSONSchemaPropsOrBool{
@ -701,6 +704,9 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
{ {
Raw: []byte(`"sqs"`), Raw: []byte(`"sqs"`),
}, },
{
Raw: []byte(`"wal"`),
},
}, },
}, },
}, },

View File

@ -233,5 +233,6 @@ type Stream struct {
Filter map[string]string `json:"filter,omitempty"` Filter map[string]string `json:"filter,omitempty"`
BatchSize uint32 `json:"batchSize,omitempty"` BatchSize uint32 `json:"batchSize,omitempty"`
SqsArn string `json:"sqsArn,omitempty"` SqsArn string `json:"sqsArn,omitempty"`
SqsFifo bool `json:"sqsFifo,omitempty"`
QueueName string `json:"queueName,omitempty"` QueueName string `json:"queueName,omitempty"`
} }

View File

@ -45,6 +45,7 @@ type EventStreamFlow struct {
DataOpColumn string `json:"dataOpColumn,omitempty"` DataOpColumn string `json:"dataOpColumn,omitempty"`
MetadataColumn string `json:"metadataColumn,omitempty"` MetadataColumn string `json:"metadataColumn,omitempty"`
DataColumn string `json:"dataColumn,omitempty"` DataColumn string `json:"dataColumn,omitempty"`
PayloadColumn string `json:"payloadColumn,omitempty"`
CallHomeIdColumn string `json:"callHomeIdColumn,omitempty"` CallHomeIdColumn string `json:"callHomeIdColumn,omitempty"`
CallHomeUrl string `json:"callHomeUrl,omitempty"` CallHomeUrl string `json:"callHomeUrl,omitempty"`
} }
@ -55,6 +56,7 @@ type EventStreamSink struct {
EventType string `json:"eventType,omitempty"` EventType string `json:"eventType,omitempty"`
MaxBatchSize uint32 `json:"maxBatchSize,omitempty"` MaxBatchSize uint32 `json:"maxBatchSize,omitempty"`
QueueName string `json:"queueName,omitempty"` QueueName string `json:"queueName,omitempty"`
QueueUrl string `json:"queueUrl,omitempty"`
} }
// EventStreamSource defines the source of the event stream and connection for FES operator // EventStreamSource defines the source of the event stream and connection for FES operator

View File

@ -142,10 +142,11 @@ func (c *Cluster) getEventStreamSource(stream acidv1.Stream, table, eventType st
Filter: streamFilter, Filter: streamFilter,
Connection: c.getStreamConnection(stream.Database, constants.EventStreamSourceSlotPrefix+constants.UserRoleNameSuffix), Connection: c.getStreamConnection(stream.Database, constants.EventStreamSourceSlotPrefix+constants.UserRoleNameSuffix),
} }
case "sqs": case "default":
return zalandov1alpha1.EventStreamSource{ return zalandov1alpha1.EventStreamSource{
Type: constants.EventStreamSourcePGType, Type: constants.EventStreamSourcePGType,
EventStreamTable: getSqsTable(table), Schema: schema,
EventStreamTable: getSourceTable(table),
Connection: c.getStreamConnection(stream.Database, constants.EventStreamSourceSlotPrefix+constants.UserRoleNameSuffix), Connection: c.getStreamConnection(stream.Database, constants.EventStreamSourceSlotPrefix+constants.UserRoleNameSuffix),
} }
} }
@ -161,12 +162,13 @@ func getEventStreamFlow(stream acidv1.Stream) zalandov1alpha1.EventStreamFlow {
DataTypeColumn: constants.EventStreamFlowDataTypeColumn, DataTypeColumn: constants.EventStreamFlowDataTypeColumn,
DataOpColumn: constants.EventStreamFlowDataOpColumn, DataOpColumn: constants.EventStreamFlowDataOpColumn,
MetadataColumn: constants.EventStreamFlowMetadataColumn, MetadataColumn: constants.EventStreamFlowMetadataColumn,
DataColumn: constants.EventStreamFlowDataColumn} DataColumn: constants.EventStreamFlowDataColumn,
case "sqs": }
case "default":
return zalandov1alpha1.EventStreamFlow{ return zalandov1alpha1.EventStreamFlow{
Type: constants.EventStreamFlowPgApiType, Type: constants.EventStreamFlowPgGenericType,
CallHomeIdColumn: "id", PayloadColumn: constants.EventStreamFlowPayloadColumn,
CallHomeUrl: stream.SqsArn} }
} }
return zalandov1alpha1.EventStreamFlow{} return zalandov1alpha1.EventStreamFlow{}
@ -174,15 +176,23 @@ func getEventStreamFlow(stream acidv1.Stream) zalandov1alpha1.EventStreamFlow {
func getEventStreamSink(stream acidv1.Stream, eventType string) zalandov1alpha1.EventStreamSink { func getEventStreamSink(stream acidv1.Stream, eventType string) zalandov1alpha1.EventStreamSink {
switch stream.StreamType { switch stream.StreamType {
case "nakadi": case "sqs":
sqsSinkType := constants.EventStreamSinkSqsStandardType
if stream.SqsFifo {
sqsSinkType = constants.EventStreamSinkSqsFifoType
}
return zalandov1alpha1.EventStreamSink{
Type: sqsSinkType,
QueueName: stream.QueueName,
QueueUrl: stream.SqsArn,
MaxBatchSize: stream.BatchSize,
}
case "default":
return zalandov1alpha1.EventStreamSink{ return zalandov1alpha1.EventStreamSink{
Type: constants.EventStreamSinkNakadiType, Type: constants.EventStreamSinkNakadiType,
EventType: eventType, EventType: eventType,
MaxBatchSize: stream.BatchSize} MaxBatchSize: stream.BatchSize,
case "sqs": }
return zalandov1alpha1.EventStreamSink{
Type: constants.EventStreamSinkSqsType,
QueueName: stream.QueueName}
} }
return zalandov1alpha1.EventStreamSink{} return zalandov1alpha1.EventStreamSink{}
@ -206,7 +216,7 @@ func getOutboxTable(tableName, eventType string) zalandov1alpha1.EventStreamTabl
} }
} }
func getSqsTable(tableName string) zalandov1alpha1.EventStreamTable { func getSourceTable(tableName string) zalandov1alpha1.EventStreamTable {
return zalandov1alpha1.EventStreamTable{ return zalandov1alpha1.EventStreamTable{
Name: outboxTableNameTemplate.Format("table", tableName), Name: outboxTableNameTemplate.Format("table", tableName),
} }

View File

@ -54,6 +54,14 @@ var (
}, },
BatchSize: uint32(100), BatchSize: uint32(100),
}, },
{
StreamType: "wal",
Database: "foo",
Tables: map[string]string{
"bar": "stream_type_a",
},
BatchSize: uint32(100),
},
{ {
StreamType: "sqs", StreamType: "sqs",
Database: "foo", Database: "foo",

View File

@ -2,15 +2,18 @@ package constants
// PostgreSQL specific constants // PostgreSQL specific constants
const ( const (
EventStreamSourcePGType = "PostgresLogicalReplication" EventStreamSourcePGType = "PostgresLogicalReplication"
EventStreamSourceSlotPrefix = "fes_" EventStreamSourceSlotPrefix = "fes_"
EventStreamSourceAuthType = "DatabaseAuthenticationSecret" EventStreamSourceAuthType = "DatabaseAuthenticationSecret"
EventStreamFlowPgNakadiType = "PostgresWalToNakadiDataEvent" EventStreamFlowPgNakadiType = "PostgresWalToNakadiDataEvent"
EventStreamFlowPgApiType = "PostgresWalToApiCallHomeEvent" EventStreamFlowPgGenericType = "PostgresWalToGenericNakadiEvent"
EventStreamFlowDataTypeColumn = "data_type" EventStreamFlowPgApiType = "PostgresWalToApiCallHomeEvent"
EventStreamFlowDataOpColumn = "data_op" EventStreamFlowDataTypeColumn = "data_type"
EventStreamFlowMetadataColumn = "metadata" EventStreamFlowDataOpColumn = "data_op"
EventStreamFlowDataColumn = "data" EventStreamFlowMetadataColumn = "metadata"
EventStreamSinkNakadiType = "Nakadi" EventStreamFlowDataColumn = "data"
EventStreamSinkSqsType = "Sqs" EventStreamFlowPayloadColumn = "payload"
EventStreamSinkNakadiType = "Nakadi"
EventStreamSinkSqsStandardType = "SqsStandard"
EventStreamSinkSqsFifoType = "SqsFifo"
) )