Skip to content

Commit

Permalink
Add consumer metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Sep 22, 2023
1 parent 3686f5f commit f4c520b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 34 deletions.
4 changes: 4 additions & 0 deletions controllers/jetstream/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ func consumerSpecToOpts(spec apis.ConsumerSpec) ([]jsm.ConsumerOption, error) {
opts = append(opts, jsm.MaxDeliveryAttempts(spec.MaxDeliver))
}

if spec.Metadata != nil {
opts = append(opts, jsm.ConsumerMetadata(spec.Metadata))
}

return opts, nil
}

Expand Down
5 changes: 5 additions & 0 deletions deploy/crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ spec:
description: Force the consumer state to be kept in memory rather than inherit the setting from the stream.
type: boolean
default: false
metadata:
description: Additional Consumer metadata.
type: object
additionalProperties:
type: string
tls:
description: A client's TLS certs and keys.
type: object
Expand Down
69 changes: 35 additions & 34 deletions pkg/jetstream/apis/jetstream/v1beta2/consumertypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,41 @@ func (c *Consumer) GetSpec() interface{} {

// ConsumerSpec is the spec for a Consumer resource
type ConsumerSpec struct {
AckPolicy string `json:"ackPolicy"`
AckWait string `json:"ackWait"`
BackOff []string `json:"backoff"`
Creds string `json:"creds"`
DeliverGroup string `json:"deliverGroup"`
DeliverPolicy string `json:"deliverPolicy"`
DeliverSubject string `json:"deliverSubject"`
Description string `json:"description"`
PreventDelete bool `json:"preventDelete"`
PreventUpdate bool `json:"preventUpdate"`
DurableName string `json:"durableName"`
FilterSubject string `json:"filterSubject"`
FilterSubjects []string `json:"filterSubjects"`
FlowControl bool `json:"flowControl"`
HeadersOnly bool `json:"headersOnly"`
HeartbeatInterval string `json:"heartbeatInterval"`
MaxAckPending int `json:"maxAckPending"`
MaxDeliver int `json:"maxDeliver"`
MaxRequestBatch int `json:"maxRequestBatch"`
MaxRequestExpires string `json:"maxRequestExpires"`
MaxRequestMaxBytes int `json:"maxRequestMaxBytes"`
MaxWaiting int `json:"maxWaiting"`
MemStorage bool `json:"memStorage"`
Nkey string `json:"nkey"`
OptStartSeq int `json:"optStartSeq"`
OptStartTime string `json:"optStartTime"`
RateLimitBps int `json:"rateLimitBps"`
ReplayPolicy string `json:"replayPolicy"`
Replicas int `json:"replicas"`
SampleFreq string `json:"sampleFreq"`
Servers []string `json:"servers"`
StreamName string `json:"streamName"`
TLS TLS `json:"tls"`
Account string `json:"account"`
AckPolicy string `json:"ackPolicy"`
AckWait string `json:"ackWait"`
BackOff []string `json:"backoff"`
Creds string `json:"creds"`
DeliverGroup string `json:"deliverGroup"`
DeliverPolicy string `json:"deliverPolicy"`
DeliverSubject string `json:"deliverSubject"`
Description string `json:"description"`
PreventDelete bool `json:"preventDelete"`
PreventUpdate bool `json:"preventUpdate"`
DurableName string `json:"durableName"`
FilterSubject string `json:"filterSubject"`
FilterSubjects []string `json:"filterSubjects"`
FlowControl bool `json:"flowControl"`
HeadersOnly bool `json:"headersOnly"`
HeartbeatInterval string `json:"heartbeatInterval"`
MaxAckPending int `json:"maxAckPending"`
MaxDeliver int `json:"maxDeliver"`
MaxRequestBatch int `json:"maxRequestBatch"`
MaxRequestExpires string `json:"maxRequestExpires"`
MaxRequestMaxBytes int `json:"maxRequestMaxBytes"`
MaxWaiting int `json:"maxWaiting"`
MemStorage bool `json:"memStorage"`
Nkey string `json:"nkey"`
OptStartSeq int `json:"optStartSeq"`
OptStartTime string `json:"optStartTime"`
RateLimitBps int `json:"rateLimitBps"`
ReplayPolicy string `json:"replayPolicy"`
Replicas int `json:"replicas"`
SampleFreq string `json:"sampleFreq"`
Servers []string `json:"servers"`
StreamName string `json:"streamName"`
TLS TLS `json:"tls"`
Account string `json:"account"`
Metadata map[string]string `json:"metadata"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
7 changes: 7 additions & 0 deletions pkg/jetstream/apis/jetstream/v1beta2/zz_generated.deepcopy.go

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

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

0 comments on commit f4c520b

Please sign in to comment.