Skip to content

Commit

Permalink
add event watcher and crd convertor
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonChen86899 committed Apr 2, 2023
1 parent 0b68e5b commit 3950ea1
Show file tree
Hide file tree
Showing 9 changed files with 662 additions and 316 deletions.
74 changes: 56 additions & 18 deletions k8s/crd/bases/event.opensergo.io_events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ spec:
EventTrigger
properties:
enable:
type: bool
type: boolean
retryTriggerThreshold:
description: Threshold value of retry triggering dead letter
format: int64
Expand Down Expand Up @@ -181,14 +181,26 @@ spec:
description: Persistence detail of persistence
properties:
fullStrategy:
type: int
type: integer
persistenceAddress:
description: PersistenceAddress address of persistence
properties:
address:
description: The storage address is determined according
to the PersistenceType For example, local file directory/usr/local/data
remote file system address xxx. xxx. xxx. xxx
type: string
required:
- address
type: object
persistenceSize:
format: int64
type: int64
type: integer
persistenceType:
type: int
type: integer
required:
- fullStrategy
- persistenceAddress
- persistenceSize
- persistenceType
type: object
Expand Down Expand Up @@ -328,7 +340,7 @@ spec:
example, P6S represents the duration of 6s
type: string
backOffPolicyType:
type: int
type: integer
retryMax:
format: int64
minimum: 1
Expand Down Expand Up @@ -475,7 +487,7 @@ spec:
example, P6S represents the duration of 6s
type: string
backOffPolicyType:
type: int
type: integer
retryMax:
format: int64
minimum: 1
Expand All @@ -497,21 +509,34 @@ spec:
description: EventSourceStrategy strategy for event source producer
properties:
asyncSend:
type: bool
type: boolean
eventSourceID:
type: string
faultTolerantStorage:
description: Persistence detail of persistence
properties:
fullStrategy:
type: int
type: integer
persistenceAddress:
description: PersistenceAddress address of persistence
properties:
address:
description: The storage address is determined according
to the PersistenceType For example, local file
directory/usr/local/data remote file system address
xxx. xxx. xxx. xxx
type: string
required:
- address
type: object
persistenceSize:
format: int64
type: int64
type: integer
persistenceType:
type: int
type: integer
required:
- fullStrategy
- persistenceAddress
- persistenceSize
- persistenceType
type: object
Expand Down Expand Up @@ -649,7 +674,7 @@ spec:
of 6s
type: string
backOffPolicyType:
type: int
type: integer
retryMax:
format: int64
minimum: 1
Expand Down Expand Up @@ -682,7 +707,7 @@ spec:
for EventTrigger
properties:
enable:
type: bool
type: boolean
retryTriggerThreshold:
description: Threshold value of retry triggering dead
letter
Expand Down Expand Up @@ -712,14 +737,27 @@ spec:
description: Persistence detail of persistence
properties:
fullStrategy:
type: int
type: integer
persistenceAddress:
description: PersistenceAddress address of persistence
properties:
address:
description: The storage address is determined
according to the PersistenceType For example,
local file directory/usr/local/data remote
file system address xxx. xxx. xxx. xxx
type: string
required:
- address
type: object
persistenceSize:
format: int64
type: int64
type: integer
persistenceType:
type: int
type: integer
required:
- fullStrategy
- persistenceAddress
- persistenceSize
- persistenceType
type: object
Expand All @@ -730,12 +768,12 @@ spec:
- storePersistence
type: object
enableIdempotence:
type: bool
type: boolean
eventTriggerID:
type: string
receiveBufferSize:
format: int64
type: int64
type: integer
runtimeStrategy:
description: EventRuntimeStrategy runtime strategy for event
source or trigger centralized setting FaultTolerance RateLimit
Expand Down Expand Up @@ -870,7 +908,7 @@ spec:
of 6s
type: string
backOffPolicyType:
type: int
type: integer
retryMax:
format: int64
minimum: 1
Expand Down
20 changes: 12 additions & 8 deletions pkg/api/v1alpha1/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,26 @@ type EventComponents struct {

// PersistenceAddress address of persistence
type PersistenceAddress struct {
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Required
// The storage address is determined according to the PersistenceType
// For example, local file directory/usr/local/data remote file system address xxx. xxx. xxx. xxx
Address string `json:"address"`
}

// Persistence detail of persistence
type Persistence struct {
// +kubebuilder:validation:Type=int
// +kubebuilder:validation:Type=integer
// +kubebuilder:validation:Required
PersistenceType int `json:"persistenceType"`

// +kubebuilder:validation:Type=int64
PersistenceAddress PersistenceAddress `json:"persistenceAddress"`

// +kubebuilder:validation:Type=integer
// +kubebuilder:validation:Required
PersistenceSize int64 `json:"persistenceSize"`

// +kubebuilder:validation:Type=int
// +kubebuilder:validation:Type=integer
// +kubebuilder:validation:Required
FullStrategy int `json:"fullStrategy"`
}
Expand All @@ -104,14 +108,14 @@ type RetryRule struct {
// for example, P6S represents the duration of 6s
BackOffDelay string `json:"backOffDelay"`

// +kubebuilder:validation:Type=int
// +kubebuilder:validation:Type=integer
// +kubebuilder:validation:Required
BackOffPolicyType int `json:"backOffPolicyType"`
}

// DeadLetterStrategy dead letter message strategy for EventTrigger
type DeadLetterStrategy struct {
// +kubebuilder:validation:Type=bool
// +kubebuilder:validation:Type=boolean
// +kubebuilder:validation:Required
Enable bool `json:"enable"`

Expand Down Expand Up @@ -147,7 +151,7 @@ type EventSourceStrategy struct {
// +kubebuilder:validation:Required
EventSourceID string `json:"eventSourceID"`

// +kubebuilder:validation:Type=bool
// +kubebuilder:validation:Type=boolean
// +kubebuilder:validation:Optional
AsyncSend bool `json:"asyncSend"`

Expand All @@ -162,11 +166,11 @@ type EventTriggerStrategy struct {
// +kubebuilder:validation:Required
EventTriggerID string `json:"eventTriggerID"`

// +kubebuilder:validation:Type=int64
// +kubebuilder:validation:Type=integer
// +kubebuilder:validation:Required
ReceiveBufferSize int64 `json:"receiveBufferSize"`

// +kubebuilder:validation:Type=bool
// +kubebuilder:validation:Type=boolean
// +kubebuilder:validation:Optional
EnableIdempotence bool `json:"enableIdempotence"`

Expand Down
1 change: 1 addition & 0 deletions pkg/api/v1alpha1/event/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions pkg/controller/crd_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package controller

import (
"github.com/opensergo/opensergo-control-plane/pkg/api/v1alpha1"
v1alpha1event "github.com/opensergo/opensergo-control-plane/pkg/api/v1alpha1/event"
"github.com/opensergo/opensergo-control-plane/pkg/api/v1alpha1/traffic"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -53,6 +54,7 @@ const (
ConcurrencyLimitStrategyKind = "fault-tolerance.opensergo.io/v1alpha1/ConcurrencyLimitStrategy"
CircuitBreakerStrategyKind = "fault-tolerance.opensergo.io/v1alpha1/CircuitBreakerStrategy"
TrafficRouterKind = "traffic.opensergo.io/v1alpha1/TrafficRouter"
EventKind = "event.opensergo.io/v1alpha1/Event"
)

var (
Expand All @@ -76,6 +78,9 @@ var (
TrafficRouterKind: NewCRDMetadata(TrafficRouterKind, func() client.Object {
return &traffic.TrafficRouter{}
}),
EventKind: NewCRDMetadata(EventKind, func() client.Object {
return &v1alpha1event.Event{}
}),
}
)

Expand Down
Loading

0 comments on commit 3950ea1

Please sign in to comment.