Skip to content

Commit

Permalink
feat: add Kafka sink messageTimeout (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored Dec 6, 2021
1 parent 1fa83f9 commit de6a76e
Show file tree
Hide file tree
Showing 14 changed files with 523 additions and 918 deletions.
1,375 changes: 460 additions & 915 deletions api/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/v1alpha1/kafka_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type KafkaSink struct {
Acks *intstr.IntOrString `json:"acks,omitempty" protobuf:"bytes,6,opt,name=acks"`
// +kubebuilder:default=true
EnableIdempotence bool `json:"enableIdempotence,omitempty" protobuf:"varint,7,opt,name=enableIdempotence"`
// +kubebuilder:default="30s"
MessageTimeout *metav1.Duration `json:"messageTimeout,omitempty" protobuf:"bytes,8,opt,name=messageTimeout"`
}

func (m *KafkaSink) GetBatchSize() int {
Expand All @@ -35,6 +37,10 @@ func (m *KafkaSink) GetLingerMs() int {
return int(m.Linger.Milliseconds())
}

func (m *KafkaSink) GetMessageTimeoutMs() int {
return int(m.MessageTimeout.Milliseconds())
}

func (m *KafkaSink) GetAcks() interface{} {
if m.Acks.Type == intstr.String {
return m.Acks.String()
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down Expand Up @@ -8841,6 +8844,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/cluster-quick-start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down Expand Up @@ -8841,6 +8844,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/dataflow.argoproj.io_pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/dataflow.argoproj.io_steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/default-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down Expand Up @@ -8841,6 +8844,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down Expand Up @@ -8841,6 +8844,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down Expand Up @@ -8841,6 +8844,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
6 changes: 6 additions & 0 deletions config/quick-start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down Expand Up @@ -8841,6 +8844,9 @@ spec:
maxMessageBytes:
format: int32
type: integer
messageTimeout:
default: 30s
type: string
name:
default: default
type: string
Expand Down
9 changes: 6 additions & 3 deletions dsls/python/argo_dataflow/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def dump(self):

class KafkaSink(Sink):
def __init__(self, subject, name=None, a_sync=False, batchSize=None, linger=None, compressionType=None, acks=None,
enableIdempotence=None):
enableIdempotence=None, messageTimeout=None):
super().__init__(name)
self._subject = subject
self._a_sync = a_sync
Expand All @@ -169,6 +169,7 @@ def __init__(self, subject, name=None, a_sync=False, batchSize=None, linger=None
self._compressionType = compressionType
self._acks = acks
self._enableIdempotence = enableIdempotence
self._messageTimeout = messageTimeout

def dump(self):
x = super().dump()
Expand All @@ -185,6 +186,8 @@ def dump(self):
y['acks'] = self._acks
if self._enableIdempotence:
y['enableIdempotence'] = self._enableIdempotence
if self._messageTimeout:
y['messageTimeout'] = self._messageTimeout
x['kafka'] = y
return x

Expand Down Expand Up @@ -232,9 +235,9 @@ def http(self, url, name=None, insecureSkipVerify=None, headers=None):
return self

def kafka(self, subject, name=None, a_sync=False, batchSize=None, linger=None, compressionType=None, acks=None,
enableIdempotence=None):
enableIdempotence=None, messageTimeout=None):
self._sinks.append(KafkaSink(subject, name=name, a_sync=a_sync, batchSize=batchSize, linger=linger,
compressionType=compressionType, acks=acks, enableIdempotence=enableIdempotence))
compressionType=compressionType, acks=acks, enableIdempotence=enableIdempotence, messageTimeout=messageTimeout))
return self

def scale(self, desiredReplicas, scalingDelay=None, peekDelay=None):
Expand Down
1 change: 1 addition & 0 deletions runner/sidecar/sink/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func New(ctx context.Context, sinkName string, secretInterface corev1.SecretInte
// https://docs.confluent.io/cloud/current/client-apps/optimizing/throughput.html
config["batch.size"] = x.GetBatchSize()
config["linger.ms"] = x.GetLingerMs()
config["message.timeout.ms"] = x.GetMessageTimeoutMs()
config["compression.type"] = x.CompressionType
config["acks"] = x.GetAcks()
config["enable.idempotence"] = x.EnableIdempotence
Expand Down

0 comments on commit de6a76e

Please sign in to comment.