Skip to content

Commit

Permalink
Update api common (#161)
Browse files Browse the repository at this point in the history
* Moving EventProtocol to api common

* Moving EventProtocol to api common
  • Loading branch information
VaibhavPage authored and magaldima committed Feb 1, 2019
1 parent 349ff86 commit 6d3d3ae
Show file tree
Hide file tree
Showing 16 changed files with 1,470 additions and 2,207 deletions.
9 changes: 8 additions & 1 deletion gateways/event-source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package gateways

import (
"context"
"github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1"
"os"
"sync"
"testing"

"github.com/argoproj/argo-events/common"
pc "github.com/argoproj/argo-events/pkg/apis/common"
"github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1"
gwfake "github.com/argoproj/argo-events/pkg/client/gateway/clientset/versioned/fake"
"github.com/smartystreets/goconvey/convey"
corev1 "k8s.io/api/core/v1"
Expand All @@ -29,6 +30,12 @@ func getGatewayConfig() *GatewayConfig {
Watchers: &v1alpha1.NotificationWatchers{
Sensors: []v1alpha1.SensorNotificationWatcher{},
},
EventProtocol: &pc.EventProtocol{
Type: pc.HTTP,
Http: pc.Http{
Port: "9000",
},
},
},
},
Clientset: fake.NewSimpleClientset(),
Expand Down
1 change: 0 additions & 1 deletion gateways/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestGatewayState(t *testing.T) {
var err error
gc.gw, err = gc.gwcs.ArgoprojV1alpha1().Gateways(gc.gw.Namespace).Create(gc.gw)
convey.So(err, convey.ShouldBeNil)

})

convey.Convey("Update gateway resource test-node node state to running", func() {
Expand Down
2 changes: 1 addition & 1 deletion hack/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ $(go run /Users/vpage/go/src/github.com/argoproj/argo-events/vendor/k8s.io/code-

# generate protocol documentation
protoc -I=${GOPATH}/src --doc_out=../docs --doc_opt=markdown,gateway-protocol.md github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1/generated.proto
protoc -I=${GOPATH}/src --doc_out=../docs --doc_opt=markdown,sensor-protocol.md github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1/generated.proto
protoc -I=${GOPATH}/src --doc_out=../docs --doc_opt=markdown,sensor-protocol.md github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1/generated.proto
1 change: 1 addition & 0 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ bash -x ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
"gateway:v1alpha1" \
--go-header-file ./custom-boilerplate.go.txt

go run ${GOPATH}/src/k8s.io/gengo/examples/deepcopy-gen/main.go -i github.com/argoproj/argo-events/pkg/apis/common -p github.com/argoproj/argo-events/pkg/apis/common
52 changes: 51 additions & 1 deletion pkg/apis/common/deepcopy_generated.go

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

48 changes: 48 additions & 0 deletions pkg/apis/common/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,51 @@ type URI struct {
Query string `json:"query" protobuf:"bytes,7,opt,name=query"`
Fragment string `json:"fragment" protobuf:"bytes,8,opt,name=fragment"`
}

// Dispatch protocol contains configuration necessary to dispatch an event to sensor over different communication protocols
type EventProtocol struct {
Type EventProtocolType `json:"type" protobuf:"bytes,1,opt,name=type"`

Http Http `json:"http" protobuf:"bytes,2,opt,name=http"`

Nats Nats `json:"nats" protobuf:"bytes,3,opt,name=nats"`
}

// Http contains the information required to setup a http server and listen to incoming events
type Http struct {
// Port on which server will run
Port string `json:"port" protobuf:"bytes,1,opt,name=port"`
}

// Nats contains the information required to connect to nats server and get subscriptions
type Nats struct {
// URL is nats server/service URL
URL string `json:"url" protobuf:"bytes,1,opt,name=url"`

// Subscribe starting with most recently published value. Refer https://github.com/nats-io/go-nats-streaming
StartWithLastReceived bool `json:"startWithLastReceived,omitempty" protobuf:"bytes,2,opt,name=startWithLastReceived"`

// Receive all stored values in order.
DeliverAllAvailable bool `json:"deliverAllAvailable,omitempty" protobuf:"bytes,3,opt,name=deliverAllAvailable"`

// Receive messages starting at a specific sequence number
StartAtSequence string `json:"startAtSequence,omitempty" protobuf:"bytes,4,opt,name=startAtSequence"`

// Subscribe starting at a specific time
StartAtTime string `json:"startAtTime,omitempty" protobuf:"bytes,5,opt,name=startAtTime"`

// Subscribe starting a specific amount of time in the past (e.g. 30 seconds ago)
StartAtTimeDelta string `json:"startAtTimeDelta,omitempty" protobuf:"bytes,6,opt,name=startAtTimeDelta"`

// Durable subscriptions allow clients to assign a durable name to a subscription when it is created
Durable bool `json:"durable,omitempty" protobuf:"bytes,7,opt,name=durable"`

// The NATS Streaming cluster ID
ClusterId string `json:"clusterId,omitempty" protobuf:"bytes,8,opt,name=clusterId"`

// The NATS Streaming cluster ID
ClientId string `json:"clientId,omitempty" protobuf:"bytes,9,opt,name=clientId"`

// Type of the connection. either standard or streaming
Type NatsType `json:"type" protobuf:"bytes,10,opt,name=type"`
}
Loading

0 comments on commit 6d3d3ae

Please sign in to comment.