From faccc94b9e649c46f29cfc9912ddd1655dfa8fcf Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 15 Nov 2023 10:30:31 -0800 Subject: [PATCH] Rename callout to http-grpc-callout --- samples/device-simulator/.gitignore | 11 ----------- samples/device-simulator/lib/external/external.go | 12 +++++++++--- samples/http-grpc-callout/.gitignore | 4 ++++ samples/http-grpc-callout/Dockerfile | 6 +++--- samples/http-grpc-callout/cmd/main.go | 10 +++++++--- samples/http-grpc-callout/go.mod | 2 +- samples/http-grpc-callout/magefile.go | 2 +- 7 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 samples/http-grpc-callout/.gitignore diff --git a/samples/device-simulator/.gitignore b/samples/device-simulator/.gitignore index deb3f06..a158792 100644 --- a/samples/device-simulator/.gitignore +++ b/samples/device-simulator/.gitignore @@ -1,15 +1,4 @@ -bin -.vscode/* -/mako -dns.yaml -/src/**/config.json /bin -/listen -/mqtt -/manager -/simulator -dist/ cover.tmp.out coverage.out -web cover.* \ No newline at end of file diff --git a/samples/device-simulator/lib/external/external.go b/samples/device-simulator/lib/external/external.go index 259ae4a..9f05629 100644 --- a/samples/device-simulator/lib/external/external.go +++ b/samples/device-simulator/lib/external/external.go @@ -230,7 +230,9 @@ func (builder *DeviceSimulatorBuilder) ParseTopicAndPublisher( ) } -func (builder *DeviceSimulatorBuilder) ParseTags(configuration Site) ([]string, error) { +func (builder *DeviceSimulatorBuilder) ParseTags( + configuration Site, +) ([]string, error) { switch configuration.PayloadFormat { case "JSONTagPerMessage": return builder.ParseJSONTagPerMessage(configuration) @@ -251,7 +253,9 @@ func (builder *DeviceSimulatorBuilder) ParseTags(configuration Site) ([]string, } } -func (builder *DeviceSimulatorBuilder) ParseAssets(configuration Site) ([]string, error) { +func (builder *DeviceSimulatorBuilder) ParseAssets( + configuration Site, +) ([]string, error) { assets := make([]string, configuration.AssetCount) for count := 0; count < configuration.AssetCount; count++ { asset, err := builder.ParseAsset(configuration, count) @@ -362,7 +366,9 @@ func (builder *DeviceSimulatorBuilder) ParseJSONTag( return tagID, nil } -func (builder *DeviceSimulatorBuilder) ParseOPCUA(configuration Site) ([]string, error) { +func (builder *DeviceSimulatorBuilder) ParseOPCUA( + configuration Site, +) ([]string, error) { err := builder.ParseFormatter( configuration.Name, formatter.JSON, diff --git a/samples/http-grpc-callout/.gitignore b/samples/http-grpc-callout/.gitignore new file mode 100644 index 0000000..a158792 --- /dev/null +++ b/samples/http-grpc-callout/.gitignore @@ -0,0 +1,4 @@ +/bin +cover.tmp.out +coverage.out +cover.* \ No newline at end of file diff --git a/samples/http-grpc-callout/Dockerfile b/samples/http-grpc-callout/Dockerfile index 62bd499..1a70d7c 100644 --- a/samples/http-grpc-callout/Dockerfile +++ b/samples/http-grpc-callout/Dockerfile @@ -4,9 +4,9 @@ FROM mcr.microsoft.com/oss/go/microsoft/golang:1.21-cbl-mariner2.0 AS build COPY ./lib /workdir/lib -COPY ./samples/callout /workdir/samples/callout +COPY ./samples/http-grpc-callout /workdir/samples/http-grpc-callout -WORKDIR /workdir/samples/callout +WORKDIR /workdir/samples/http-grpc-callout RUN go mod download @@ -14,7 +14,7 @@ RUN go install github.com/magefile/mage@latest RUN mage ci -RUN go build -o ./bin/callout ./cmd/callout +RUN go build -o ./bin/http-grpc-callout ./cmd/http-grpc-callout EXPOSE 2112 diff --git a/samples/http-grpc-callout/cmd/main.go b/samples/http-grpc-callout/cmd/main.go index af68aac..d58d803 100644 --- a/samples/http-grpc-callout/cmd/main.go +++ b/samples/http-grpc-callout/cmd/main.go @@ -103,9 +103,13 @@ func run() error { grpcOutputs[index] = o } - messageServer := NewGRPCMessageServer(grpcOutputs, &proto.ProtoEncoder{}, func(gs *GRPCMessageServer) { - gs.Logger = lg.Tag("server").Tag("grpc") - }) + messageServer := NewGRPCMessageServer( + grpcOutputs, + &proto.ProtoEncoder{}, + func(gs *GRPCMessageServer) { + gs.Logger = lg.Tag("server").Tag("grpc") + }, + ) grpcServer := grpc.NewServer() proto.RegisterSenderServer(grpcServer, messageServer) diff --git a/samples/http-grpc-callout/go.mod b/samples/http-grpc-callout/go.mod index 62127ef..b1dad87 100644 --- a/samples/http-grpc-callout/go.mod +++ b/samples/http-grpc-callout/go.mod @@ -1,4 +1,4 @@ -module github.com/explore-iot-ops/samples/callout +module github.com/explore-iot-ops/samples/http-grpc-callout go 1.21.3 diff --git a/samples/http-grpc-callout/magefile.go b/samples/http-grpc-callout/magefile.go index 9ce8b12..0fe4bc2 100644 --- a/samples/http-grpc-callout/magefile.go +++ b/samples/http-grpc-callout/magefile.go @@ -14,7 +14,7 @@ import ( func CI() error { return mage.CI( - "github.com/explore-iot-ops/samples/callout/", + "github.com/explore-iot-ops/samples/http-grpc-callout/", map[string]any{"cmd": nil}, 3000, 0.00,