diff --git a/samples/http-grpc-callout/.gitignore b/samples/http-grpc-callout/.gitignore deleted file mode 100644 index a158792..0000000 --- a/samples/http-grpc-callout/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/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 deleted file mode 100644 index 1e98a94..0000000 --- a/samples/http-grpc-callout/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# syntax=docker/dockerfile:1 - -FROM mcr.microsoft.com/oss/go/microsoft/golang:1.21-cbl-mariner2.0 AS build -LABEL org.opencontainers.image.source=https://github.com/Azure-Samples/explore-iot-operations -LABEL org.opencontainers.image.description="HTTP & GRPC callout server" -LABEL org.opencontainers.image.licenses=MIT - -COPY ./lib /workdir/lib - -COPY ./samples/http-grpc-callout /workdir/samples/http-grpc-callout - -WORKDIR /workdir/samples/http-grpc-callout - -RUN go mod download - -RUN go install github.com/magefile/mage@latest - -RUN mage ci - -RUN go build -o ./bin/http-grpc-callout ./cmd - -EXPOSE 2112 - -CMD [ "./bin/http-grpc-callout" ] diff --git a/samples/http-grpc-callout/README.md b/samples/http-grpc-callout/README.md deleted file mode 100644 index 80dc548..0000000 --- a/samples/http-grpc-callout/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# GRPC/HTTP Callout Server - -GRPC/HTTP Callout Server is a server for testing the http and grpc callout capabilities of the Azure IoT Operations data processor. - -## Quick Start - -```sh -kubectl apply -f manifest.yml -``` - -## Usage - -### Build Image from Source - -```sh -# From the root of the http-grpc-callout directory. -docker build ../.. -f Dockerfile -t ghcr.io/azure-samples/explore-iot-operations/http-grpc-callout:latest - -# Or if running from the root of the explore-iot-operations repository. -# docker build . -f ./samples/http-grpc-callout/Dockerfile -t ghcr.io/azure-samples/explore-iot-operations/http-grpc-callout:latest - -# Push or load your newly built image into your cluster, depending on the k8s setup. -# docker push ghcr.io/azure-samples/explore-iot-operations/http-grpc-callout:latest # Using AKS + Connected ACR -# minikube load ghcr.io/azure-samples/explore-iot-operations/http-grpc-callout:latest # Using minikube -# docker save ghcr.io/azure-samples/explore-iot-operations/http-grpc-callout:latest | k3s ctr images import - # Using K3s - -kubectl apply -f manifest.yml -``` - -### Configuration - -```yaml -logger: # Log level (trace: 0, debug: 1, info: 2, warn: 3, error: 4, critical: 5, fatal: 6, panic: 7) - level: 0 -servers: - http: - port: 3333 # Port on which to host the HTTP server. - resources: # List of resources to host for the HTTP server. - - path: /example # Route of the resource. - method: GET # Method from which to obtain the resource. - status: 200 # Status to be returned when this resource is requested. - outputs: ["output1", "output2"] # Output destinations to send the HTTP request body, if such a request body is present (see output setup below). - response: | # Response to be returned when this resource is requested. - { - "hello": "world" - } - - path: /example - method: POST - status: 200 - outputs: ["output3", "output4"] - response: | - { - "hello": "world1" - } - grpc: - port: 3334 # Port to host the grpc server. - outputs: ['output1', 'output4'] # Outputs of the GRPC server. -outputs: # Outputs are places which HTTP and GRPC request bodies can be forwarded, such that they can be observed. - - name: output1 # Name of the output, which is used to cross reference the outputs listed in the HTTP server and GRPC server definitions. - type: stdout # Type of the output (either stdout or mqtt). - - name: output2 - type: mqtt - qos: 1 # For MQTT type outputs, qos determines the qos level of the message being sent. - path: default/output1 # Path at which to send the mqtt output message. - endpoint: localhost:1883 # Endpoint of the mqtt broker. - - name: output3 - type: mqtt - qos: 1 - path: default/output2 - endpoint: localhost:1883 - - name: output4 - type: mqtt - qos: 1 - path: grpc/example - endpoint: localhost:1883 -``` \ No newline at end of file diff --git a/samples/http-grpc-callout/cmd/config.go b/samples/http-grpc-callout/cmd/config.go deleted file mode 100644 index 146eca5..0000000 --- a/samples/http-grpc-callout/cmd/config.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -package main - -type Configuration struct { - LoggerConfiguration `json:"logger" yaml:"logger"` - ServerConfiguration `json:"servers" yaml:"servers"` - Outputs []Output `json:"outputs" yaml:"outputs"` -} - -type LoggerConfiguration struct { - Level int `json:"level" yaml:"level"` -} - -type ServerConfiguration struct { - HTTPServer `json:"http" yaml:"http"` - GRPCServer `json:"grpc" yaml:"grpc"` -} - -type HTTPServer struct { - Resources []Resource `json:"resources" yaml:"resources"` - Port int `json:"port" yaml:"port"` -} - -type GRPCServer struct { - Outputs []string `json:"outputs" yaml:"outputs"` - Port int `json:"port" yaml:"port"` -} - -type Resource struct { - Path string `json:"path" yaml:"path"` - Method string `json:"method" yaml:"method"` - Status int `json:"status" yaml:"status"` - Response string `json:"response" yaml:"response"` - Outputs []string `json:"outputs" yaml:"outputs"` -} - -type Output struct { - Name string `json:"name" yaml:"name"` - Path string `json:"path" yaml:"path"` - Type string `json:"type" yaml:"type"` - QoS int `json:"qos" yaml:"qos"` - Endpoint string `json:"endpoint" yaml:"endpoint"` -} diff --git a/samples/http-grpc-callout/cmd/grpc.go b/samples/http-grpc-callout/cmd/grpc.go deleted file mode 100644 index 8713abd..0000000 --- a/samples/http-grpc-callout/cmd/grpc.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -package main - -import ( - "context" - "encoding/json" - - "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/lib/proto" -) - -type GRPCMessageServer struct { - proto.UnimplementedSenderServer - outputs []Out - encoder proto.Encoder - Logger logger.Logger -} - -func NewGRPCMessageServer( - outputs []Out, - encoder proto.Encoder, - options ...func(*GRPCMessageServer), -) *GRPCMessageServer { - server := &GRPCMessageServer{ - outputs: outputs, - encoder: encoder, - Logger: &logger.NoopLogger{}, - } - - for _, option := range options { - option(server) - } - - return server -} - -func (server *GRPCMessageServer) Send( - ctx context.Context, - m *proto.Message, -) (*proto.Message, error) { - server.Logger.Level(logger.Debug).Printf("received new grpc message") - - res := server.encoder.Decode(m) - - content, err := json.Marshal(res) - if err != nil { - return nil, err - } - - for _, output := range server.outputs { - err := output.Out(content) - if err != nil { - return nil, err - } - } - - return &proto.Message{}, nil -} diff --git a/samples/http-grpc-callout/cmd/main.go b/samples/http-grpc-callout/cmd/main.go deleted file mode 100644 index d58d803..0000000 --- a/samples/http-grpc-callout/cmd/main.go +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -package main - -import ( - "encoding/json" - "fmt" - "io" - "net" - "os" - - "github.com/explore-iot-ops/lib/env" - "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/lib/proto" - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog/log" - "google.golang.org/grpc" - "gopkg.in/yaml.v3" -) - -func main() { - err := run() - if err != nil { - panic(err) - } -} - -func run() error { - app := fiber.New(fiber.Config{ - DisableStartupMessage: true, - }) - - flagParser := env.NewFlagParser() - - flags, err := flagParser.ReadFlags(map[string]any{ - "config": "./config.yml", - "yaml": true, - "stdin": true, - }) - if err != nil { - return err - } - - unmarshal := yaml.Unmarshal - if !(*flags["yaml"].(*bool)) { - unmarshal = json.Unmarshal - } - - configReader := env.New[Configuration]( - func(cr *env.ConfigurationReader[Configuration]) { - cr.Unmarshal = unmarshal - if *flags["stdin"].(*bool) { - cr.ReadFile = func(_ string) ([]byte, error) { - return io.ReadAll(os.Stdin) - } - } - }, - ) - - configuration, err := configReader.Read(*flags["config"].(*string)) - if err != nil { - return err - } - - lis, err := net.Listen( - "tcp", - fmt.Sprintf(":%d", configuration.GRPCServer.Port), - ) - if err != nil { - return err - } - - lg := logger.NewZeroLoggerWrapper( - log.Logger, - func(zlw *logger.ZeroLoggerWrapper) { - zlw.LogLevel = configuration.LoggerConfiguration.Level - }, - ) - - outputs := NewOutputCollection( - configuration.Outputs, - func(oc *OutputCollection) { - oc.Logger = lg.Tag("outputs") - }, - ) - - err = outputs.Setup() - if err != nil { - return err - } - - httpServer := New(app, configuration.HTTPServer, outputs, func(s *Server) { - s.Logger = lg.Tag("server").Tag("http") - }) - - grpcOutputs := make([]Out, len(configuration.GRPCServer.Outputs)) - for index, output := range configuration.GRPCServer.Outputs { - o, err := outputs.Get(output) - if err != nil { - return err - } - grpcOutputs[index] = o - } - - messageServer := NewGRPCMessageServer( - grpcOutputs, - &proto.ProtoEncoder{}, - func(gs *GRPCMessageServer) { - gs.Logger = lg.Tag("server").Tag("grpc") - }, - ) - grpcServer := grpc.NewServer() - proto.RegisterSenderServer(grpcServer, messageServer) - - go func() { - err := grpcServer.Serve(lis) - if err != nil { - panic(err) - } - }() - - return httpServer.Start() -} diff --git a/samples/http-grpc-callout/cmd/output.go b/samples/http-grpc-callout/cmd/output.go deleted file mode 100644 index a8da8a8..0000000 --- a/samples/http-grpc-callout/cmd/output.go +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -package main - -import ( - "context" - "fmt" - "net" - "strings" - - mqttv5 "github.com/eclipse/paho.golang/paho" - "github.com/explore-iot-ops/lib/logger" -) - -type InvalidOutputNameError struct { - name string -} - -func (err *InvalidOutputNameError) Error() string { - return fmt.Sprintf( - "the output with the name %q could not be found", - err.name, - ) -} - -type InvalidOutputTypeError struct { - output string -} - -func (err *InvalidOutputTypeError) Error() string { - return fmt.Sprintf("%q is not a valid output type", err.output) -} - -type Out interface { - Out(content []byte) error -} - -type OutputCollection struct { - m map[string]Out - outputs []Output - Logger logger.Logger -} - -func NewOutputCollection( - outputs []Output, - options ...func(*OutputCollection), -) *OutputCollection { - collection := &OutputCollection{ - m: make(map[string]Out), - outputs: outputs, - } - - for _, option := range options { - option(collection) - } - - return collection -} - -func (collection *OutputCollection) Get(name string) (Out, error) { - res, ok := collection.m[name] - if !ok { - return nil, &InvalidOutputNameError{ - name: name, - } - } - - return res, nil -} - -func (collection *OutputCollection) Setup() error { - for _, output := range collection.outputs { - err := collection.Output(output) - if err != nil { - return err - } - } - - return nil -} - -func (collection *OutputCollection) Output(output Output) error { - switch strings.ToLower(output.Type) { - case "mqtt": - o, err := NewMQTTOutput(output) - if err != nil { - return err - } - collection.m[output.Name] = o - case "stdout": - collection.m[output.Name] = NewStdoutOutput(func(so *StdoutOutput) { - so.Logger = collection.Logger - }) - default: - return &InvalidOutputTypeError{ - output: output.Type, - } - } - - return nil -} - -type MQTTOutput struct { - cli *mqttv5.Client - topic string - qos int -} - -func NewMQTTOutput(output Output) (*MQTTOutput, error) { - conn, err := net.Dial("tcp", output.Endpoint) - if err != nil { - return nil, err - } - - cli := mqttv5.NewClient(mqttv5.ClientConfig{ - Router: mqttv5.NewStandardRouter(), - Conn: conn, - ClientID: output.Name, - }) - cli.ClientID = output.Name - - cp := &mqttv5.Connect{ - KeepAlive: 5, - CleanStart: true, - ClientID: output.Name, - } - _, err = cli.Connect(context.Background(), cp) - if err != nil { - return nil, err - } - - return &MQTTOutput{ - cli: cli, - topic: output.Path, - qos: output.QoS, - }, nil -} - -func (output *MQTTOutput) Out(content []byte) error { - _, err := output.cli.Publish(context.Background(), &mqttv5.Publish{ - QoS: byte(output.qos), - Topic: output.topic, - Payload: content, - }) - return err -} - -type StdoutOutput struct { - Logger logger.Logger -} - -func NewStdoutOutput(options ...func(*StdoutOutput)) *StdoutOutput { - out := &StdoutOutput{ - Logger: &logger.NoopLogger{}, - } - - for _, option := range options { - option(out) - } - - return out -} - -func (output *StdoutOutput) Out(content []byte) error { - output.Logger.Level(logger.Debug). - With("content", string(content)). - Printf("server received new content") - return nil -} diff --git a/samples/http-grpc-callout/cmd/server.go b/samples/http-grpc-callout/cmd/server.go deleted file mode 100644 index ee3fdf3..0000000 --- a/samples/http-grpc-callout/cmd/server.go +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -package main - -import ( - "fmt" - "strings" - - "github.com/explore-iot-ops/lib/logger" - "github.com/gofiber/fiber/v2" -) - -type InvalidMethodError struct { - method string -} - -func (err *InvalidMethodError) Error() string { - return fmt.Sprintf("%q is not a support http method", err.method) -} - -type Server struct { - app *fiber.App - configuration HTTPServer - outputs *OutputCollection - Logger logger.Logger -} - -func New( - app *fiber.App, - configuration HTTPServer, - outputs *OutputCollection, - options ...func(*Server), -) *Server { - server := &Server{ - app: app, - configuration: configuration, - outputs: outputs, - Logger: &logger.NoopLogger{}, - } - - for _, option := range options { - option(server) - } - - return server -} - -func (server *Server) Start() error { - for _, resource := range server.configuration.Resources { - server.Logger.Level(logger.Info). - With("method", resource.Method). - With("status", fmt.Sprintf("%d", resource.Status)). - With("path", resource.Path). - Printf("registering new route") - err := server.Resource(resource) - if err != nil { - return err - } - } - - server.Logger.Level(logger.Info). - With("port", fmt.Sprintf("%d", server.configuration.Port)). - Printf("configuration parsed successfully, now hosting server") - return server.app.Listen(fmt.Sprintf(":%d", server.configuration.Port)) -} - -func (server *Server) Resource(resource Resource) error { - f, err := server.Handlerfunc(resource) - if err != nil { - return err - } - switch strings.ToLower(resource.Method) { - case "get": - server.app.Get(resource.Path, f) - case "post": - server.app.Post(resource.Path, f) - case "put": - server.app.Put(resource.Path, f) - case "patch": - server.app.Put(resource.Path, f) - default: - return &InvalidMethodError{ - method: resource.Method, - } - } - - return nil -} - -func (server *Server) Handlerfunc( - resource Resource, -) (func(c *fiber.Ctx) error, error) { - - outputs := make([]Out, len(resource.Outputs)) - - for index, output := range resource.Outputs { - o, err := server.outputs.Get(output) - if err != nil { - return nil, err - } - outputs[index] = o - } - - return func(c *fiber.Ctx) error { - server.Logger.Level(logger.Debug). - With("ip", c.IP()). - With("method", c.Method()). - Printf("incoming request") - - body := c.Body() - - for _, output := range outputs { - err := output.Out(body) - if err != nil { - server.Logger.Level(logger.Error). - With("error", err.Error()). - Printf("could not output request body") - } - } - - c.Status(resource.Status) - return c.Send([]byte(resource.Response)) - }, nil -} diff --git a/samples/http-grpc-callout/go.mod b/samples/http-grpc-callout/go.mod deleted file mode 100644 index 4f96861..0000000 --- a/samples/http-grpc-callout/go.mod +++ /dev/null @@ -1,47 +0,0 @@ -module github.com/explore-iot-ops/samples/http-grpc-callout - -go 1.21.3 - -replace ( - github.com/explore-iot-ops/lib/env => ../../lib/env - github.com/explore-iot-ops/lib/logger => ../../lib/logger - github.com/explore-iot-ops/lib/mage => ../../lib/mage - github.com/explore-iot-ops/lib/proto => ../../lib/proto -) - -require ( - github.com/eclipse/paho.golang v0.12.0 - github.com/explore-iot-ops/lib/env v0.0.0-00010101000000-000000000000 - github.com/explore-iot-ops/lib/logger v0.0.0-00010101000000-000000000000 - github.com/explore-iot-ops/lib/mage v0.0.0-00010101000000-000000000000 - github.com/explore-iot-ops/lib/proto v0.0.0-00010101000000-000000000000 - github.com/gofiber/fiber/v2 v2.51.0 - github.com/rs/zerolog v1.31.0 - google.golang.org/grpc v1.59.0 - gopkg.in/yaml.v3 v3.0.1 -) - -require ( - github.com/VividCortex/ewma v1.1.1 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect - github.com/cheggaaa/pb/v3 v3.0.4 // indirect - github.com/fatih/color v1.9.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/uuid v1.4.0 // indirect - github.com/klauspost/compress v1.16.7 // indirect - github.com/magefile/mage v1.15.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/princjef/mageutil v1.0.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.50.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sync v0.4.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/text v0.13.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/protobuf v1.31.0 // indirect -) diff --git a/samples/http-grpc-callout/go.sum b/samples/http-grpc-callout/go.sum deleted file mode 100644 index 00f7340..0000000 --- a/samples/http-grpc-callout/go.sum +++ /dev/null @@ -1,100 +0,0 @@ -github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM= -github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/cheggaaa/pb v2.0.7+incompatible/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= -github.com/cheggaaa/pb/v3 v3.0.4 h1:QZEPYOj2ix6d5oEg63fbHmpolrnNiwjUsk+h74Yt4bM= -github.com/cheggaaa/pb/v3 v3.0.4/go.mod h1:7rgWxLrAUcFMkvJuv09+DYi7mMUYi8nO9iOWcvGJPfw= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/eclipse/paho.golang v0.12.0 h1:EXQFJbJklDnUqW6lyAknMWRhM2NgpHxwrrL8riUmp3Q= -github.com/eclipse/paho.golang v0.12.0/go.mod h1:TSDCUivu9JnoR9Hl+H7sQMcHkejWH2/xKK1NJGtLbIE= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofiber/fiber/v2 v2.51.0 h1:JNACcZy5e2tGApWB2QrRpenTWn0fq0hkFm6k0C86gKQ= -github.com/gofiber/fiber/v2 v2.51.0/go.mod h1:xaQRZQJGqnKOQnbQw+ltvku3/h8QxvNi8o6JiJ7Ll0U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= -github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= -github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= -github.com/matryer/is v1.3.0 h1:9qiso3jaJrOe6qBRJRBt2Ldht05qDiFP9le0JOIhRSI= -github.com/matryer/is v1.3.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/princjef/mageutil v1.0.0 h1:1OfZcJUMsooPqieOz2ooLjI+uHUo618pdaJsbCXcFjQ= -github.com/princjef/mageutil v1.0.0/go.mod h1:mkShhaUomCYfAoVvTKRcbAs8YSVPdtezI5j6K+VXhrs= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.50.0 h1:H7fweIlBm0rXLs2q0XbalvJ6r0CUPFWK3/bB4N13e9M= -github.com/valyala/fasthttp v1.50.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/VividCortex/ewma.v1 v1.1.1/go.mod h1:TekXuFipeiHWiAlO1+wSS23vTcyFau5u3rxXUSXj710= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/cheggaaa/pb.v2 v2.0.7/go.mod h1:0CiZ1p8pvtxBlQpLXkHuUTpdJ1shm3OqCF1QugkjHL4= -gopkg.in/fatih/color.v1 v1.7.0/go.mod h1:P7yosIhqIl/sX8J8UypY5M+dDpD2KmyfP5IRs5v/fo0= -gopkg.in/mattn/go-colorable.v0 v0.1.0/go.mod h1:BVJlBXzARQxdi3nZo6f6bnl5yR20/tOL6p+V0KejgSY= -gopkg.in/mattn/go-isatty.v0 v0.0.4/go.mod h1:wt691ab7g0X4ilKZNmMII3egK0bTxl37fEn/Fwbd8gc= -gopkg.in/mattn/go-runewidth.v0 v0.0.4/go.mod h1:BmXejnxvhwdaATwiJbB1vZ2dtXkQKZGu9yLFCZb4msQ= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/samples/http-grpc-callout/magefile.go b/samples/http-grpc-callout/magefile.go deleted file mode 100644 index 0fe4bc2..0000000 --- a/samples/http-grpc-callout/magefile.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -//go:build mage - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -package main - -import ( - //mage:import - "github.com/explore-iot-ops/lib/mage" -) - -func CI() error { - return mage.CI( - "github.com/explore-iot-ops/samples/http-grpc-callout/", - map[string]any{"cmd": nil}, - 3000, - 0.00, - 0, - ) -} diff --git a/samples/http-grpc-callout/manifest.yml b/samples/http-grpc-callout/manifest.yml deleted file mode 100644 index d116f01..0000000 --- a/samples/http-grpc-callout/manifest.yml +++ /dev/null @@ -1,227 +0,0 @@ ---- -apiVersion: v1 -kind: ConfigMap -metadata: - namespace: azure-iot-operations - name: callout-conf -data: - config.yml: |- - logger: - level: 0 - servers: - http: - port: 3333 - resources: - - path: /example - method: GET - status: 200 - outputs: ["output1"] - response: | - { - "hello": "world" - } - - path: /ref_data - method: GET - status: 200 - outputs: ["output1"] - response: | - [ - { - "assetID": "Sea_O1", - "serialNumber": "SN001", - "name": "Contoso", - "site": "Seattle", - "maintenanceStatus": "Done" - }, - { - "assetID": "Red_O1", - "serialNumber": "SN002", - "name": "Contoso", - "site": "Redmond", - "maintenanceStatus": "Upcoming" - }, - { - "assetID": "Tac_O1", - "serialNumber": "SN003", - "name": "Contoso", - "site": "Tacoma", - "maintenanceStatus": "Overdue" - }, - { - "assetID": "Sea_S1", - "serialNumber": "SN004", - "name": "Contoso", - "site": "Seattle", - "maintenanceStatus": "Done" - }, - { - "assetID": "Red_S1", - "serialNumber": "SN005", - "name": "Contoso", - "site": "Redmond", - "maintenanceStatus": "Done" - }, - { - "assetID": "Sea_M1", - "serialNumber": "SN007", - "name": "Contoso", - "site": "Seattle", - "maintenanceStatus": "Done" - }, - { - "assetID": "Red_M1", - "serialNumber": "SN008", - "name": "Contoso", - "site": "Redmond", - "maintenanceStatus": "Overdue" - }, - { - "assetID": "Tac_M1", - "serialNumber": "SN009", - "name": "Contoso", - "site": "Tacoma", - "maintenanceStatus": "Done" - }, - { - "assetID": "Tac_S1", - "serialNumber": "SN010", - "name": "Contoso", - "site": "Tacoma", - "maintenanceStatus": "Upcoming" - } - ] - - path: /ts - method: GET - status: 200 - outputs: ["output1"] - response: | - { - "timestamp": "2023-11-16T8:18:10-08:00" - } - - path: /productionData - method: GET - status: 200 - outputs: ["output1"] - response: | - [ - { - "Line":"Line1", - "ProductId":"Bagel", - "Customer":"Contoso", - "Manufacturer": "Fabrikam" - }, - { - "Line":"Line2", - "ProductId":"Donut", - "Customer":"Contoso", - "Manufacturer": "Northwind" - } - ] - - path: /operatorData - method: GET - status: 200 - outputs: ["output1"] - response: | - [ - { - "Shift":0, - "Operator":"Bob", - "PerformanceTarget":45, - "PackagedProductTarget":12960 - }, - { - "Shift":1, - "Operator":"Anne", - "PerformanceTarget":60, - "PackagedProductTarget":17280 - }, - { - "Shift":2, - "Operator":"Cameron", - "PerformanceTarget":50, - "PackagedProductTarget":14400 - } - ] - grpc: - port: 3334 - outputs: ["output1"] - outputs: - - name: output1 - type: stdout ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: azure-iot-operations - name: http-grpc-callout - labels: - app: http-grpc-callout -spec: - replicas: 1 - selector: - matchLabels: - app: http-grpc-callout - template: - metadata: - labels: - app: http-grpc-callout - spec: - containers: - - name: http-grpc-callout - image: ghcr.io/azure-samples/explore-iot-operations/http-grpc-callout:latest - imagePullPolicy: Always - ports: - - name: http - containerPort: 3333 - - name: grpc - containerPort: 3334 - resources: - requests: - memory: "64Mi" - cpu: "250m" - limits: - memory: "128Mi" - cpu: "500m" - command: - - "./bin/http-grpc-callout" - - "--stdin=false" - - "--config=/etc/http-grpc-callout/config.yml" - volumeMounts: - - mountPath: /etc/http-grpc-callout/config.yml - subPath: config.yml - name: config - readOnly: true - volumes: - - name: config - configMap: - name: callout-conf ---- -apiVersion: v1 -kind: Service -metadata: - namespace: azure-iot-operations - name: callout-svc-http - labels: - app: http-grpc-callout -spec: - ports: - - port: 3333 - name: http - type: ClusterIP - selector: - app: http-grpc-callout ---- -apiVersion: v1 -kind: Service -metadata: - namespace: azure-iot-operations - name: callout-svc-grpc - labels: - app: http-grpc-callout -spec: - ports: - - port: 3334 - name: grpc - type: ClusterIP - selector: - app: http-grpc-callout