Skip to content

Commit

Permalink
feat: add primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
wenfengwang committed Feb 11, 2022
1 parent 3cf463f commit c1d209c
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# How about contributing to Vanus

TODO
## Guides

### CLA
You must sign the Contributor License Agreement(TODO) in order to contribute.

### TODO

65 changes: 65 additions & 0 deletions internal/primitive/subscription.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2022 Linkall Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package primitive

type URI string

type Subscription struct {
ID string `json:"id"`
Source string `json:"source"`
Types []string `json:"types"`
Config map[string]string `json:"config"`
Filters []map[string]string `json:"filters"`
Sink URI `json:"sink"`
Protocol string `json:"protocol"`
ProtocolSettings map[string]string `json:"protocolsettings"`
}

type SinkSpec struct {
Type string
Name string // TODO use id or name? ID used in CloudEvents Specification
Weight float32
Config map[string]interface{}
}

type DialectType string

const (
ExactDialect = "exact"
PrefixDialect = "prefix"
SuffixDialect = "suffix"
AllDialect = "all"
AnyDialect = "any"
NotDialect = "not"
SQLDialect = "ce-sql"
)

type FilterSpec struct {
Name string
Exp interface{}
ApplyTo []string
Target TargetSpec
}

type SubscriptionSpec struct {
EventBuses []string
Sinks []SinkSpec
Filters []FilterSpec
}

type TargetSpec struct {
LBStrategy string
Sinks []string
}
34 changes: 34 additions & 0 deletions internal/primitive/trigger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2022 Linkall Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package primitive

type TriggerState string

const (
TriggerCreated = "created"
TriggerPending = "pending"
TriggerRunning = "running"
TriggerSleep = "sleep"
TriggerPaused = "paused"
TriggerStopped = "stopped"
TriggerDestroyed = "destroyed"
)

type Trigger struct {
ID string `json:"id"`
SubscriptionID string `json:"subscription_id"`
State TriggerState `json:"state"`
// other fields will be added in coding
}

0 comments on commit c1d209c

Please sign in to comment.