|
| 1 | +/* |
| 2 | +RabbitMQ Messaging Topology Kubernetes Operator |
| 3 | +Copyright 2021 VMware, Inc. |
| 4 | +
|
| 5 | +This product is licensed to you under the Mozilla Public License 2.0 license (the "License"). You may not use this product except in compliance with the Mozilla 2.0 License. |
| 6 | +
|
| 7 | +This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file. |
| 8 | +*/ |
| 9 | + |
| 10 | +package v1alpha1 |
| 11 | + |
| 12 | +import ( |
| 13 | + topologyv1beta1 "github.com/rabbitmq/messaging-topology-operator/api/v1beta1" |
| 14 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 15 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 16 | +) |
| 17 | + |
| 18 | +// SuperStreamSpec defines the desired state of SuperStream |
| 19 | +type SuperStreamSpec struct { |
| 20 | + // Name of the queue; required property. |
| 21 | + // +kubebuilder:validation:Required |
| 22 | + Name string `json:"name"` |
| 23 | + // Default to vhost '/'; cannot be updated |
| 24 | + // +kubebuilder:default:=/ |
| 25 | + Vhost string `json:"vhost,omitempty"` |
| 26 | + // Number of partitions to create within this super stream. |
| 27 | + // Defaults to '3'. |
| 28 | + // +kubebuilder:default:=3 |
| 29 | + Partitions int `json:"partitions,omitempty"` |
| 30 | + // Routing keys to use for each of the partitions in the SuperStream |
| 31 | + // If unset, the routing keys for the partitions will be set to the index of the partitions |
| 32 | + // +kubebuilder:validation:Optional |
| 33 | + RoutingKeys []string `json:"routingKeys,omitempty"` |
| 34 | + // Reference to the RabbitmqCluster that the SuperStream will be created in. |
| 35 | + // Required property. |
| 36 | + // +kubebuilder:validation:Required |
| 37 | + RabbitmqClusterReference topologyv1beta1.RabbitmqClusterReference `json:"rabbitmqClusterReference"` |
| 38 | +} |
| 39 | + |
| 40 | +// SuperStreamStatus defines the observed state of SuperStream |
| 41 | +type SuperStreamStatus struct { |
| 42 | + // observedGeneration is the most recent successful generation observed for this SuperStream. It corresponds to the |
| 43 | + // SuperStream's generation, which is updated on mutation by the API Server. |
| 44 | + ObservedGeneration int64 `json:"observedGeneration,omitempty"` |
| 45 | + Conditions []topologyv1beta1.Condition `json:"conditions,omitempty"` |
| 46 | + // Partitions are a list of the stream queue names which form the partitions of this SuperStream. |
| 47 | + Partitions []string `json:"partitions,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +// +genclient |
| 51 | +// +kubebuilder:object:root=true |
| 52 | +// +kubebuilder:resource:categories=all |
| 53 | +// +kubebuilder:subresource:status |
| 54 | + |
| 55 | +// SuperStream is the Schema for the queues API |
| 56 | +type SuperStream struct { |
| 57 | + metav1.TypeMeta `json:",inline"` |
| 58 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 59 | + |
| 60 | + Spec SuperStreamSpec `json:"spec,omitempty"` |
| 61 | + Status SuperStreamStatus `json:"status,omitempty"` |
| 62 | +} |
| 63 | + |
| 64 | +// +kubebuilder:object:root=true |
| 65 | + |
| 66 | +// SuperStreamList contains a list of SuperStreams |
| 67 | +type SuperStreamList struct { |
| 68 | + metav1.TypeMeta `json:",inline"` |
| 69 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 70 | + Items []SuperStream `json:"items"` |
| 71 | +} |
| 72 | + |
| 73 | +func (q *SuperStream) GroupResource() schema.GroupResource { |
| 74 | + return schema.GroupResource{ |
| 75 | + Group: q.GroupVersionKind().Group, |
| 76 | + Resource: q.GroupVersionKind().Kind, |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +func init() { |
| 81 | + SchemeBuilder.Register(&SuperStream{}, &SuperStreamList{}) |
| 82 | +} |
0 commit comments