Skip to content

Commit

Permalink
feat: customize maxBytes and maxMsgs for EventBus (#1272)
Browse files Browse the repository at this point in the history
* feat: customize maxBytes and maxMsgs for EventBus

Signed-off-by: Derek Wang <[email protected]>
  • Loading branch information
whynowy authored Jul 2, 2021
1 parent 4163d44 commit b38bed1
Show file tree
Hide file tree
Showing 11 changed files with 270 additions and 89 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ RUN apk update && apk upgrade && \
apk add ca-certificates && \
apk --no-cache add tzdata

ENV ARGO_VERSION=v3.0.2
ENV ARGO_VERSION=v3.1.1

RUN wget -q https://github.com/argoproj/argo/releases/download/${ARGO_VERSION}/argo-linux-${ARCH}.gz
RUN wget -q https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-${ARCH}.gz
RUN gunzip -f argo-linux-${ARCH}.gz
RUN chmod +x argo-linux-${ARCH}
RUN mv ./argo-linux-${ARCH} /usr/local/bin/argo
Expand Down
22 changes: 22 additions & 0 deletions api/event-bus.html

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

21 changes: 21 additions & 0 deletions api/event-bus.md

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

9 changes: 9 additions & 0 deletions api/openapi-spec/swagger.json

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

12 changes: 11 additions & 1 deletion controllers/eventbus/installer/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,14 @@ func (i *natsInstaller) buildConfigMap() (*corev1.ConfigMap, error) {
if err != nil {
return nil, err
}
maxMsgs := uint64(1000000)
if i.eventBus.Spec.NATS.Native.MaxMsgs != nil {
maxMsgs = *i.eventBus.Spec.NATS.Native.MaxMsgs
}
maxBytes := "1GB"
if i.eventBus.Spec.NATS.Native.MaxBytes != nil {
maxBytes = *i.eventBus.Spec.NATS.Native.MaxBytes
}
peers := []string{}
routes := []string{}
for j := 0; j < replicas; j++ {
Expand All @@ -470,8 +478,10 @@ streaming {
}
store_limits {
max_age: %s
max_msgs: %v
max_bytes: %s
}
}`, strconv.Itoa(int(monitorPort)), strconv.Itoa(int(clusterPort)), strings.Join(routes, ","), clusterID, strings.Join(peers, ","), maxAge)
}`, strconv.Itoa(int(monitorPort)), strconv.Itoa(int(clusterPort)), strings.Join(routes, ","), clusterID, strings.Join(peers, ","), maxAge, maxMsgs, maxBytes)
cm := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: i.eventBus.Namespace,
Expand Down
6 changes: 5 additions & 1 deletion docs/eventbus.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ affinity:

#### More About Native NATS EventBus

- Messages limit is 1,000,000.
- Messages limit per channel defaults to 1,000,000. It could be customized by
setting `spec.nats.native.maxMsgs`, `0` means unlimited.

- Message bytes per channel defaults to `1GB`, setting
`spec.nats.native.maxBytes` to customize it, `"0"` means unlimited.

- Max age of messages is 72 hours, which means messages over 72 hours will be
deleted automatically. It can be cutomized by setting
Expand Down
251 changes: 166 additions & 85 deletions pkg/apis/eventbus/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pkg/apis/eventbus/v1alpha1/generated.proto

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

14 changes: 14 additions & 0 deletions pkg/apis/eventbus/v1alpha1/openapi_generated.go

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

4 changes: 4 additions & 0 deletions pkg/apis/eventbus/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ type NativeStrategy struct {
// More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty" protobuf:"bytes,16,opt,name=affinity"`
// Maximum number of messages per channel, 0 means unlimited. Defaults to 1000000
MaxMsgs *uint64 `json:"maxMsgs,omitempty" protobuf:"bytes,17,opt,name=maxMsgs"`
// Total size of messages per channel, 0 means unlimited. Defaults to 1GB
MaxBytes *string `json:"maxBytes,omitempty" protobuf:"bytes,18,opt,name=maxBytes"`
}

// ContainerTemplate defines customized spec for a container
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/eventbus/v1alpha1/zz_generated.deepcopy.go

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

0 comments on commit b38bed1

Please sign in to comment.