From 75b18e692d1898e55c372cf7b44cc669cf212963 Mon Sep 17 00:00:00 2001 From: Aneesh Puttur Date: Wed, 7 Sep 2022 15:16:54 -0400 Subject: [PATCH] Updated sdk Signed-off-by: Aneesh Puttur --- go.mod | 2 +- go.sum | 4 ++-- .../redhat-cne/sdk-go/pkg/channel/data.go | 23 +++++++++++++++---- vendor/modules.txt | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f07da9c..e699f43 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 github.com/prometheus/client_golang v1.11.0 - github.com/redhat-cne/sdk-go v0.1.1-0.20220829185317-30eb4ee8e2f6 + github.com/redhat-cne/sdk-go v0.1.1-0.20220907191325-02b031866855 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 golang.org/x/net v0.0.0-20210614182718-04defd469f4e diff --git a/go.sum b/go.sum index 26c8af9..7bd2348 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/redhat-cne/sdk-go v0.1.1-0.20220829185317-30eb4ee8e2f6 h1:AjWsrSwYrWWUX8M+zBydWozmplIyjkYVIhMUs7LbX1A= -github.com/redhat-cne/sdk-go v0.1.1-0.20220829185317-30eb4ee8e2f6/go.mod h1:oiSLb2ub22f7hLZshVwzER4VgY8Q0gkdtD6j5bAbWVc= +github.com/redhat-cne/sdk-go v0.1.1-0.20220907191325-02b031866855 h1:xdRtqjKmyuUmZ+gYRy5rhmC65xEa6LlWY606swuPquY= +github.com/redhat-cne/sdk-go v0.1.1-0.20220907191325-02b031866855/go.mod h1:oiSLb2ub22f7hLZshVwzER4VgY8Q0gkdtD6j5bAbWVc= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= diff --git a/vendor/github.com/redhat-cne/sdk-go/pkg/channel/data.go b/vendor/github.com/redhat-cne/sdk-go/pkg/channel/data.go index d6c83a5..3a95975 100644 --- a/vendor/github.com/redhat-cne/sdk-go/pkg/channel/data.go +++ b/vendor/github.com/redhat-cne/sdk-go/pkg/channel/data.go @@ -16,21 +16,34 @@ package channel import ( cloudevents "github.com/cloudevents/sdk-go/v2" + "github.com/google/uuid" ) // DataChan ... type DataChan struct { - ID string - Address string - Data *cloudevents.Event - Status Status + ID string + ClientID uuid.UUID + Address string + Data *cloudevents.Event + Status Status //Type defines type of data (Notification,Metric,Status) Type Type // OnReceiveFn to do on OnReceive OnReceiveFn func(e cloudevents.Event) // OnReceiveOverrideFn Optional for event, but override for status pings.This is an override function on receiving msg by amqp listener, - // if not set then the data is sent to out channel and processed by side car default method + // if not set then the data is sent to out channel and processed by side-car default method OnReceiveOverrideFn func(e cloudevents.Event, dataChan *DataChan) error // ProcessEventFn Optional, this allows to customize message handler thar was received at the out channel ProcessEventFn func(e interface{}) error } + +// CreateCloudEvents ... +func (d *DataChan) CreateCloudEvents(dataType string) (*cloudevents.Event, error) { + ce := cloudevents.NewEvent(cloudevents.VersionV03) + ce.SetDataContentType(cloudevents.ApplicationJSON) + ce.SetSpecVersion(cloudevents.VersionV03) + ce.SetType(dataType) + ce.SetSource(d.Address) + ce.SetID(d.ClientID.String()) + return &ce, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 39277fd..89a2af2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -71,7 +71,7 @@ github.com/prometheus/common/model github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util -# github.com/redhat-cne/sdk-go v0.1.1-0.20220829185317-30eb4ee8e2f6 +# github.com/redhat-cne/sdk-go v0.1.1-0.20220907191325-02b031866855 ## explicit; go 1.17 github.com/redhat-cne/sdk-go/pkg/channel github.com/redhat-cne/sdk-go/pkg/event