From 79e3ed835cc64f541f45f0f7ed96b07af04ca1ae Mon Sep 17 00:00:00 2001 From: ethanperry1 <107274017+ethanperry1@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:05:32 -0800 Subject: [PATCH] Ethanperry/add package copy headers (#30) Renames several samples, adds headers to files, and cleans up documentation and readmes. --- ...t_build.yml => device_simulator_build.yml} | 8 +- ...out_test.yml => device_simulator_test.yml} | 6 +- ..._build.yml => http_grpc_callout_build.yml} | 8 +- ...ll_test.yml => http_grpc_callout_test.yml} | 6 +- README.md | 11 ++- docs/ORGANIZATION.md | 56 ++++-------- samples/callout/cover.tmp.out | 1 - samples/callout/coverage.out | 1 - samples/device-simulator/.gitignore | 4 + .../{krill => device-simulator}/.golangci.yml | 0 .../{krill => device-simulator}/Dockerfile | 8 +- samples/{krill => device-simulator}/README.md | 73 +++++++++++----- .../krill => device-simulator/cmd}/main.go | 49 ++++++----- .../components/broker/broker.go | 7 +- .../components/broker/broker_test.go | 3 + .../components/broker/service.go | 9 +- .../components/broker/service_test.go | 9 +- .../components/client/client.go | 9 +- .../components/client/client_test.go | 7 +- .../components/client/clientv5.go | 3 + .../components/client/errors.go | 5 +- .../components/client/service.go | 15 ++-- .../components/client/service_test.go | 13 +-- .../components/edge/edge_test.go | 7 +- .../components/edge/errors.go | 7 +- .../components/edge/service.go | 9 +- .../components/formatter/errors.go | 5 +- .../components/formatter/formatter.go | 9 +- .../components/formatter/formatter_test.go | 7 +- .../components/formatter/service.go | 9 +- .../components/formatter/service_test.go | 5 +- .../components/limiter/errors.go | 5 +- .../components/limiter/limiter.go | 3 + .../components/limiter/limiter_test.go | 3 + .../components/limiter/service.go | 5 +- .../components/limiter/service_test.go | 5 +- .../components/node/errors.go | 5 +- .../components/node/node_test.go | 7 +- .../components/node/service.go | 9 +- .../components/observer/observer.go | 5 +- .../components/observer/observer_test.go | 5 +- .../components/observer/service.go | 9 +- .../components/observer/service_test.go | 9 +- .../components/outlet/outlet.go | 9 +- .../components/outlet/outlet_test.go | 9 +- .../components/outlet/service.go | 11 ++- .../components/outlet/service_test.go | 9 +- .../components/provider/errors.go | 5 +- .../components/provider/provider.go | 5 +- .../components/provider/provider_test.go | 5 +- .../components/provider/service.go | 13 +-- .../components/provider/service_test.go | 13 +-- .../components/publisher/publisher.go | 19 ++-- .../components/publisher/publisher_test.go | 23 ++--- .../components/publisher/service.go | 21 +++-- .../components/publisher/service_test.go | 17 ++-- .../components/registry/registry.go | 5 +- .../components/registry/registry_test.go | 3 + .../components/registry/service.go | 5 +- .../components/registry/service_test.go | 5 +- .../components/renderer/renderer.go | 9 +- .../components/renderer/renderer_test.go | 9 +- .../components/renderer/service.go | 9 +- .../components/renderer/service_test.go | 9 +- .../components/site/service.go | 9 +- .../components/site/service_test.go | 7 +- .../components/site/site.go | 7 +- .../components/site/site_test.go | 3 + .../components/subscriber/service.go | 17 ++-- .../components/subscriber/service_test.go | 15 ++-- .../components/subscriber/subscriber.go | 15 ++-- .../components/subscriber/subscriber_test.go | 13 +-- .../components/topic/service.go | 9 +- .../components/topic/service_test.go | 7 +- .../components/topic/topic.go | 7 +- .../components/topic/topic_test.go | 3 + .../components/tracer/service.go | 9 +- .../components/tracer/service_test.go | 7 +- .../components/tracer/tracer.go | 5 +- .../components/tracer/tracer_test.go | 5 +- .../configs/simple/config.yml | 0 samples/{krill => device-simulator}/go.mod | 2 +- samples/{krill => device-simulator}/go.sum | 0 .../lib/binary/binary.go | 3 + .../lib/binary/binary_test.go | 3 + .../lib/component/component.go | 3 + .../lib/component/component_test.go | 3 + .../lib/component/errors.go | 3 + .../lib/component/mock.go | 3 + .../lib/component/store.go | 3 + .../lib/component/store_test.go | 3 + .../lib/composition/composition.go | 5 +- .../lib/composition/composition_test.go | 5 +- .../lib/composition/mock.go | 3 + .../lib/counter/counter.go | 9 +- .../lib/counter/counter_test.go | 3 + .../lib/dialer/dialer.go | 5 +- .../lib/dialer/dialer_test.go | 3 + .../lib/environment/environment.go | 3 + .../lib/environment/environment_test.go | 3 + .../lib/errors/errors.go | 3 + .../lib/errors/errors_test.go | 3 + .../lib/errors/fiber.go | 3 + .../lib/exporter/exporter.go | 5 +- .../lib/exporter/exporter_test.go | 5 +- .../lib/exporter/mock.go | 5 +- .../lib/exporter/provider.go | 5 +- .../lib/exporter/stat.go | 3 + .../lib/expression/expression.go | 5 +- .../lib/expression/expression_test.go | 3 + .../lib/external}/configuration.go | 35 +++----- .../lib/external/external.go} | 87 ++++++++++--------- .../lib/external/external_test.go} | 67 +++++++------- .../lib/flatten/flatten.go | 3 + .../lib/flatten/flatten_test.go | 3 + .../lib/gauge/gauge.go | 7 +- .../lib/gauge/gauge_test.go | 3 + .../lib/histogram/histogram.go | 9 +- .../lib/histogram/histogram_test.go | 3 + .../lib/templater/templater.go | 5 +- .../lib/templater/templater_test.go | 5 +- .../{callout => device-simulator}/magefile.go | 7 +- samples/http-grpc-callout/.gitignore | 4 + .../{callout => http-grpc-callout}/Dockerfile | 6 +- samples/http-grpc-callout/README.md | 68 +++++++++++++++ .../cmd/config.go | 3 + .../cmd/config.yml | 6 +- .../cmd/grpc.go | 3 + .../cmd/main.go | 13 ++- .../cmd/output.go | 3 + .../cmd/server.go | 3 + samples/{callout => http-grpc-callout}/go.mod | 2 +- samples/{callout => http-grpc-callout}/go.sum | 0 samples/http-grpc-callout/magefile.go | 23 +++++ samples/krill/.gitignore | 16 ---- samples/krill/magefile.go | 18 ---- 136 files changed, 846 insertions(+), 451 deletions(-) rename .github/workflows/{callout_build.yml => device_simulator_build.yml} (70%) rename .github/workflows/{callout_test.yml => device_simulator_test.yml} (54%) rename .github/workflows/{krill_build.yml => http_grpc_callout_build.yml} (70%) rename .github/workflows/{krill_test.yml => http_grpc_callout_test.yml} (53%) delete mode 100644 samples/callout/cover.tmp.out delete mode 100644 samples/callout/coverage.out create mode 100644 samples/device-simulator/.gitignore rename samples/{krill => device-simulator}/.golangci.yml (100%) rename samples/{krill => device-simulator}/Dockerfile (55%) rename samples/{krill => device-simulator}/README.md (75%) rename samples/{krill/cmd/krill => device-simulator/cmd}/main.go (74%) rename samples/{krill => device-simulator}/components/broker/broker.go (84%) rename samples/{krill => device-simulator}/components/broker/broker_test.go (86%) rename samples/{krill => device-simulator}/components/broker/service.go (73%) rename samples/{krill => device-simulator}/components/broker/service_test.go (87%) rename samples/{krill => device-simulator}/components/client/client.go (97%) rename samples/{krill => device-simulator}/components/client/client_test.go (98%) rename samples/{krill => device-simulator}/components/client/clientv5.go (99%) rename samples/{krill => device-simulator}/components/client/errors.go (79%) rename samples/{krill => device-simulator}/components/client/service.go (85%) rename samples/{krill => device-simulator}/components/client/service_test.go (96%) rename samples/{krill => device-simulator}/components/edge/edge_test.go (96%) rename samples/{krill => device-simulator}/components/edge/errors.go (87%) rename samples/{krill => device-simulator}/components/edge/service.go (85%) rename samples/{krill => device-simulator}/components/formatter/errors.go (68%) rename samples/{krill => device-simulator}/components/formatter/formatter.go (93%) rename samples/{krill => device-simulator}/components/formatter/formatter_test.go (94%) rename samples/{krill => device-simulator}/components/formatter/service.go (80%) rename samples/{krill => device-simulator}/components/formatter/service_test.go (94%) rename samples/{krill => device-simulator}/components/limiter/errors.go (78%) rename samples/{krill => device-simulator}/components/limiter/limiter.go (96%) rename samples/{krill => device-simulator}/components/limiter/limiter_test.go (94%) rename samples/{krill => device-simulator}/components/limiter/service.go (85%) rename samples/{krill => device-simulator}/components/limiter/service_test.go (91%) rename samples/{krill => device-simulator}/components/node/errors.go (80%) rename samples/{krill => device-simulator}/components/node/node_test.go (91%) rename samples/{krill => device-simulator}/components/node/service.go (81%) rename samples/{krill => device-simulator}/components/observer/observer.go (89%) rename samples/{krill => device-simulator}/components/observer/observer_test.go (90%) rename samples/{krill => device-simulator}/components/observer/service.go (75%) rename samples/{krill => device-simulator}/components/observer/service_test.go (92%) rename samples/{krill => device-simulator}/components/outlet/outlet.go (80%) rename samples/{krill => device-simulator}/components/outlet/outlet_test.go (86%) rename samples/{krill => device-simulator}/components/outlet/service.go (74%) rename samples/{krill => device-simulator}/components/outlet/service_test.go (90%) rename samples/{krill => device-simulator}/components/provider/errors.go (70%) rename samples/{krill => device-simulator}/components/provider/provider.go (88%) rename samples/{krill => device-simulator}/components/provider/provider_test.go (78%) rename samples/{krill => device-simulator}/components/provider/service.go (83%) rename samples/{krill => device-simulator}/components/provider/service_test.go (92%) rename samples/{krill => device-simulator}/components/publisher/publisher.go (84%) rename samples/{krill => device-simulator}/components/publisher/publisher_test.go (81%) rename samples/{krill => device-simulator}/components/publisher/service.go (77%) rename samples/{krill => device-simulator}/components/publisher/service_test.go (93%) rename samples/{krill => device-simulator}/components/registry/registry.go (94%) rename samples/{krill => device-simulator}/components/registry/registry_test.go (93%) rename samples/{krill => device-simulator}/components/registry/service.go (75%) rename samples/{krill => device-simulator}/components/registry/service_test.go (79%) rename samples/{krill => device-simulator}/components/renderer/renderer.go (70%) rename samples/{krill => device-simulator}/components/renderer/renderer_test.go (73%) rename samples/{krill => device-simulator}/components/renderer/service.go (74%) rename samples/{krill => device-simulator}/components/renderer/service_test.go (88%) rename samples/{krill => device-simulator}/components/site/service.go (73%) rename samples/{krill => device-simulator}/components/site/service_test.go (90%) rename samples/{krill => device-simulator}/components/site/site.go (79%) rename samples/{krill => device-simulator}/components/site/site_test.go (72%) rename samples/{krill => device-simulator}/components/subscriber/service.go (79%) rename samples/{krill => device-simulator}/components/subscriber/service_test.go (94%) rename samples/{krill => device-simulator}/components/subscriber/subscriber.go (84%) rename samples/{krill => device-simulator}/components/subscriber/subscriber_test.go (89%) rename samples/{krill => device-simulator}/components/topic/service.go (73%) rename samples/{krill => device-simulator}/components/topic/service_test.go (90%) rename samples/{krill => device-simulator}/components/topic/topic.go (80%) rename samples/{krill => device-simulator}/components/topic/topic_test.go (84%) rename samples/{krill => device-simulator}/components/tracer/service.go (77%) rename samples/{krill => device-simulator}/components/tracer/service_test.go (90%) rename samples/{krill => device-simulator}/components/tracer/tracer.go (89%) rename samples/{krill => device-simulator}/components/tracer/tracer_test.go (84%) rename samples/{krill => device-simulator}/configs/simple/config.yml (100%) rename samples/{krill => device-simulator}/go.mod (97%) rename samples/{krill => device-simulator}/go.sum (100%) rename samples/{krill => device-simulator}/lib/binary/binary.go (94%) rename samples/{krill => device-simulator}/lib/binary/binary_test.go (95%) rename samples/{krill => device-simulator}/lib/component/component.go (81%) rename samples/{krill => device-simulator}/lib/component/component_test.go (95%) rename samples/{krill => device-simulator}/lib/component/errors.go (59%) rename samples/{krill => device-simulator}/lib/component/mock.go (93%) rename samples/{krill => device-simulator}/lib/component/store.go (94%) rename samples/{krill => device-simulator}/lib/component/store_test.go (95%) rename samples/{krill => device-simulator}/lib/composition/composition.go (95%) rename samples/{krill => device-simulator}/lib/composition/composition_test.go (94%) rename samples/{krill => device-simulator}/lib/composition/mock.go (84%) rename samples/{krill => device-simulator}/lib/counter/counter.go (93%) rename samples/{krill => device-simulator}/lib/counter/counter_test.go (96%) rename samples/{krill => device-simulator}/lib/dialer/dialer.go (95%) rename samples/{krill => device-simulator}/lib/dialer/dialer_test.go (96%) rename samples/{krill => device-simulator}/lib/environment/environment.go (90%) rename samples/{krill => device-simulator}/lib/environment/environment_test.go (87%) rename samples/{krill => device-simulator}/lib/errors/errors.go (88%) rename samples/{krill => device-simulator}/lib/errors/errors_test.go (97%) rename samples/{krill => device-simulator}/lib/errors/fiber.go (96%) rename samples/{krill => device-simulator}/lib/exporter/exporter.go (95%) rename samples/{krill => device-simulator}/lib/exporter/exporter_test.go (97%) rename samples/{krill => device-simulator}/lib/exporter/mock.go (87%) rename samples/{krill => device-simulator}/lib/exporter/provider.go (87%) rename samples/{krill => device-simulator}/lib/exporter/stat.go (85%) rename samples/{krill => device-simulator}/lib/expression/expression.go (98%) rename samples/{krill => device-simulator}/lib/expression/expression_test.go (98%) rename samples/{krill/lib/krill => device-simulator/lib/external}/configuration.go (73%) rename samples/{krill/lib/krill/krill.go => device-simulator/lib/external/external.go} (83%) rename samples/{krill/lib/krill/krill_test.go => device-simulator/lib/external/external_test.go} (90%) rename samples/{krill => device-simulator}/lib/flatten/flatten.go (96%) rename samples/{krill => device-simulator}/lib/flatten/flatten_test.go (96%) rename samples/{krill => device-simulator}/lib/gauge/gauge.go (91%) rename samples/{krill => device-simulator}/lib/gauge/gauge_test.go (96%) rename samples/{krill => device-simulator}/lib/histogram/histogram.go (94%) rename samples/{krill => device-simulator}/lib/histogram/histogram_test.go (96%) rename samples/{krill => device-simulator}/lib/templater/templater.go (93%) rename samples/{krill => device-simulator}/lib/templater/templater_test.go (93%) rename samples/{callout => device-simulator}/magefile.go (56%) create mode 100644 samples/http-grpc-callout/.gitignore rename samples/{callout => http-grpc-callout}/Dockerfile (59%) create mode 100644 samples/http-grpc-callout/README.md rename samples/{callout => http-grpc-callout}/cmd/config.go (93%) rename samples/{callout => http-grpc-callout}/cmd/config.yml (83%) rename samples/{callout => http-grpc-callout}/cmd/grpc.go (92%) rename samples/{callout => http-grpc-callout}/cmd/main.go (89%) rename samples/{callout => http-grpc-callout}/cmd/output.go (97%) rename samples/{callout => http-grpc-callout}/cmd/server.go (97%) rename samples/{callout => http-grpc-callout}/go.mod (96%) rename samples/{callout => http-grpc-callout}/go.sum (100%) create mode 100644 samples/http-grpc-callout/magefile.go delete mode 100644 samples/krill/.gitignore delete mode 100644 samples/krill/magefile.go diff --git a/.github/workflows/callout_build.yml b/.github/workflows/device_simulator_build.yml similarity index 70% rename from .github/workflows/callout_build.yml rename to .github/workflows/device_simulator_build.yml index 935805d..9c3948f 100644 --- a/.github/workflows/callout_build.yml +++ b/.github/workflows/device_simulator_build.yml @@ -1,17 +1,17 @@ -name: callout_build +name: device-simulator_build on: workflow_dispatch: push: tags: - - 'v*.*.*-callout' + - 'v*.*.*-device-simulator' jobs: call-docker-build: uses: ./.github/workflows/docker_build.yml with: - registry: makocr.azurecr.io/callout - file: samples/callout/Dockerfile + registry: makocr.azurecr.io/device-simulator + file: samples/device-simulator/Dockerfile context: . secrets: azureCredentials: ${{ secrets.AZURE_CREDENTIALS }} diff --git a/.github/workflows/callout_test.yml b/.github/workflows/device_simulator_test.yml similarity index 54% rename from .github/workflows/callout_test.yml rename to .github/workflows/device_simulator_test.yml index 6a566f7..abcade5 100644 --- a/.github/workflows/callout_test.yml +++ b/.github/workflows/device_simulator_test.yml @@ -1,13 +1,13 @@ -name: krill_test +name: device-simulator_test on: workflow_dispatch: push: paths: - - samples/callout/** + - samples/device-simulator/** jobs: call-mage-test: uses: ./.github/workflows/mage_tests.yml with: - workdir: samples/callout/ \ No newline at end of file + workdir: samples/device-simulator/ \ No newline at end of file diff --git a/.github/workflows/krill_build.yml b/.github/workflows/http_grpc_callout_build.yml similarity index 70% rename from .github/workflows/krill_build.yml rename to .github/workflows/http_grpc_callout_build.yml index 741c332..f68fd8a 100644 --- a/.github/workflows/krill_build.yml +++ b/.github/workflows/http_grpc_callout_build.yml @@ -1,17 +1,17 @@ -name: krill_build +name: http_grpc_callout_build on: workflow_dispatch: push: tags: - - 'v*.*.*-krill' + - 'v*.*.*-http-grpc-callout' jobs: call-docker-build: uses: ./.github/workflows/docker_build.yml with: - registry: makocr.azurecr.io/krill - file: samples/krill/Dockerfile + registry: makocr.azurecr.io/http-grpc-callout + file: samples/http-grpc-callout/Dockerfile context: . secrets: azureCredentials: ${{ secrets.AZURE_CREDENTIALS }} diff --git a/.github/workflows/krill_test.yml b/.github/workflows/http_grpc_callout_test.yml similarity index 53% rename from .github/workflows/krill_test.yml rename to .github/workflows/http_grpc_callout_test.yml index 316ba90..236b557 100644 --- a/.github/workflows/krill_test.yml +++ b/.github/workflows/http_grpc_callout_test.yml @@ -1,13 +1,13 @@ -name: krill_test +name: http_grpc_callout_test on: workflow_dispatch: push: paths: - - samples/krill/** + - samples/http-grpc-callout/** jobs: call-mage-test: uses: ./.github/workflows/mage_tests.yml with: - workdir: samples/krill/ \ No newline at end of file + workdir: samples/http-grpc-callout/ \ No newline at end of file diff --git a/README.md b/README.md index 0f7b06b..466a5ed 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ -# Azure IoT Operations Dev Toolbox +# Explore IoT Operations -This repo is the source of tools, samples, and other resources for customers of Azure IoT Operations. +This repo is the source of tools, samples, tutorials, and other resources for customers of Azure IoT Operations. ## Features -This project provides the following tools: +This project provides the following: * Pre-configured codespace with [K3s](https://k3s.io/) cluster via [K3d](https://k3d.io/) -* Krill MQTT Data Simulator -* HTTP Callout Server -* GRPC Callout Server +* MQTT Device Simulator +* HTTP & GRPC Callout Server > [!IMPORTANT] > Codespaces are easy to setup quickly and tear down later, but they're not suitable for performance evaluation or scale testing. For those scenarios, use a validated environment from the official documentation. diff --git a/docs/ORGANIZATION.md b/docs/ORGANIZATION.md index f0d8d63..08898a9 100644 --- a/docs/ORGANIZATION.md +++ b/docs/ORGANIZATION.md @@ -1,55 +1,31 @@ -# Toolbox Organization +# Explore IoT Operations Organization ## Structure -The AIO toolbox is a collection of several tools for customers of AIO. To keep the project understandable and extensible to future additions, the following conventions should be followed for repository structure. +Explore IoT Operations is a collection of tools and samples for customers of Azure IoT Operations. To keep the project understandable and extensible to future additions, the following conventions should be followed for repository structure. ``` -├── lib -│ ├── library1 +├── lib/ +│ ├── library1/ │ ├── ... -│ ├── libraryN -├── samples -│ ├── tool1 -│ │ ├── config.yml -│ │ ├── config.json +│ ├── libraryN/ +├── samples/ +│ ├── sample1/ │ ├── ... -│ ├── toolN -├── tools -│ ├── tool1 -│ │ ├── cmd -│ │ │ ├── main.go -│ │ ├── pkg -│ │ │ ├── pkg1 -│ ├── ... -│ ├── toolN -├── docker -│ ├── tool1 -│ │ ├── Dockerfile -│ ├── ... -│ ├── toolN -├── go.mod -├── go.sum -├── magefile.go +│ ├── sampleN/ +├── scripts/ +├── tutorials/ └── README.md ``` -__Libraries__ which are shared between multiple tools should be stored in the lib directory. This library can be incorporated into projects beyond AIO tools and such documentation will be available on the _go.dev_ documentation site. - -__Samples__ are configuration files which have been created for specific sample usages of a tool. Multiple configuration files can live in each sample folder for different samples which utilize the same tool. - -__Tools__ are AIO specific tools which may have their own internal packages stored within the pkg folder. Other top-level folders in each tool are allowed, though it is recommended to minimize the number of top-level folders. Each tool must also have its own cmd directory where the entrypoint is located. - -__Dockerfiles__ for relavent docker images are stored for each tool under the docker directory. They are siloed into their own directories for each tool. - -__Mage Commands__ are located within the magefile.go. Mage commands should be written in such a way that they apply to any given tool based on a parameter. Mage commands should not be targeted at a specific tool itself. If such a command is required, a magefile within the tool directory should be produced. +**Libraries** (`./lib`) are shared between multiple tools or samples. -## Linting & Formatting Requirements +**Samples** (`./samples`) are tools or code samples which can be written in any language. They should be given a descriptive name which adequately describes their purpose, and should include some level of documentation regarding their usage. -Linting and formatting rules are applied to all tools and libraries based on a linting configuration set up and applied via mage commands. +**Scripts** (`./scripts`) are bash scripts smaller than a tool or sample which are in some way used for setup. -## Example Tool +**Tutorials** (`./tutorials`) are collections of code and documentation which are used together to provide a step-by-step walkthrough to demonstrate the capabilities of some feature of Azure IoT Operations. These typically serve a more narrow scope than that of a tool or code sample, designed to exercise specific facets of Azure IoT Operations. -Please view the example tool in `tools/example` for an example of how to contribute a new tool to the AIO toolbox. +## Linting, Formatting, and Testing Requirements -_Note_: tools can be written in any language including minimal tools such as bash scripts. The tools are written in golang in this document for example purposes. \ No newline at end of file +Linting, formatting, and testing are not required but are highly recommended. The mage library under `./lib/mage` is provided for golang projects and offers some basic commands for linting, formatting, building, testing, and assuring test coverage bars. Comments describe each function within the library. See `./samples/device-simulation/mage.go` for an example of how this library is used. diff --git a/samples/callout/cover.tmp.out b/samples/callout/cover.tmp.out deleted file mode 100644 index 79b28a0..0000000 --- a/samples/callout/cover.tmp.out +++ /dev/null @@ -1 +0,0 @@ -mode: atomic diff --git a/samples/callout/coverage.out b/samples/callout/coverage.out deleted file mode 100644 index 79b28a0..0000000 --- a/samples/callout/coverage.out +++ /dev/null @@ -1 +0,0 @@ -mode: atomic diff --git a/samples/device-simulator/.gitignore b/samples/device-simulator/.gitignore new file mode 100644 index 0000000..a158792 --- /dev/null +++ b/samples/device-simulator/.gitignore @@ -0,0 +1,4 @@ +/bin +cover.tmp.out +coverage.out +cover.* \ No newline at end of file diff --git a/samples/krill/.golangci.yml b/samples/device-simulator/.golangci.yml similarity index 100% rename from samples/krill/.golangci.yml rename to samples/device-simulator/.golangci.yml diff --git a/samples/krill/Dockerfile b/samples/device-simulator/Dockerfile similarity index 55% rename from samples/krill/Dockerfile rename to samples/device-simulator/Dockerfile index 151648d..b20ed57 100644 --- a/samples/krill/Dockerfile +++ b/samples/device-simulator/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/krill /workdir/samples/krill +COPY ./samples/device-simulator /workdir/samples/device-simulator -WORKDIR /workdir/samples/krill +WORKDIR /workdir/samples/device-simulator RUN go mod download @@ -14,8 +14,8 @@ RUN go install github.com/magefile/mage@latest RUN mage ci -RUN go build -o ./bin/krill ./cmd/krill +RUN go build -o ./bin/device-simulator ./cmd EXPOSE 2112 -CMD [ "/bin/krill" ] +CMD [ "/bin/device-simulator" ] diff --git a/samples/krill/README.md b/samples/device-simulator/README.md similarity index 75% rename from samples/krill/README.md rename to samples/device-simulator/README.md index e7cb586..83d357a 100644 --- a/samples/krill/README.md +++ b/samples/device-simulator/README.md @@ -1,32 +1,34 @@ -# Krill +# Device Simulator ``` -⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣤⣤⣀⠀⠀⠀⠀⠀⠀ -⠀⠀⢀⣀⡙⠻⢶⣶⣦⣴⣶⣶⣶⠾⠛⠛⠋⠉⠉⠉⠉⠙⠃⠀⠀⠀⠀⠀ -⠀⠀⠀⠉⠉⠙⠛⠛⠋⠉⠉⠡⣤⣴⣶⣶⣾⣿⣿⣿⣛⣩⣤⡤⠖⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⢠⣴⣾⠂⣴⣦⠈⣿⣿⣿⣿⣿⣿⠿⠛⣋⠁⠀⠀⠀⠀⠀ -⠀⠀⢀⣼⣿⣶⣄⡉⠻⣧⣌⣁⣴⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀⠀⠀ -⠀⠀⣾⣿⣿⣿⣿⣿⣦⡈⢻⣿⣿⣿⣿⡿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⡀⢻⣿⣿⣿⣿⣿⣿⣿⡄⠙⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⢠⣷⣄⡉⠻⢿⣿⣿⣿⠏⠠⢶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⢸⣿⣿⣿⣶⣤⣈⠙⠁⠰⣦⣀⠉⠻⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠘⢿⣿⣿⣿⣿⣿⡇⠠⣦⣄⠉⠳⣤⠈⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⢠⣌⣉⡉⠉⣉⡁⠀⠀⠙⠗⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠹⢿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠙⠻⣿⣿⠟⢀⣤⡀⠀⠀⠀⠀⠀⠀⣀⣀⣠⣤⣤⣤⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠿⠿⡿⠂⣀⣠⣤⣤⣤⣀⣉⣉⠉⠉⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠛⠛⠛⠛⠋⠉⠉⠁ + ____ _ _____ _ _ _ +| \ ___ _ _|_|___ ___ | __|_|_____ _ _| |___| |_ ___ ___ +| | | -_| | | | _| -_| |__ | | | | | | .'| _| . | _| +|____/|___|\_/|_|___|___| |_____|_|_|_|_|___|_|__,|_| |___|_| ``` -Krill is a highly configurable MQTT asset simulator. +Device Simulator is a highly configurable MQTT asset simulator. ## Usage -### Krill as K8s Pod +### Device Simulator as K8s Pod -`kubectl run krill --image=azbluefin.azurecr.io/krill:latest --stdin < config.yml` +```sh +# From the root of the device-simulator directory. +docker build ../.. -f Dockerfile -t .azurecr.io/device-simulator:latest -Krill runs as a pod within the desired cluster using the kubectl run command. The configuration of choice is provided via stdin of the krill process within the pod, provided in the command above using `--stdin < config.yml`. Alternative names for a configuration file may be used -- the command simply uses stdin piping to provide krill with an appropriate configuration. +# Or if running from the root of the explore-iot-operations repository. +# docker build . -f ./samples/device-simulator/Dockerfile -t .azurecr.io/device-simulator:latest + +# Push or load your newly built image into your cluster, depending on the k8s setup. +# docker push .azurecr.io/device-simulator:latest # Using AKS + Connected ACR +# minikube load .azurecr.io/device-simulator:latest # Using minikube +# docker save .azurecr.io/device-simulator:latest | k3s ctr images import - # Using K3s + +kubectl run device-simulator --image=.azurecr.io/device-simulator:latest --stdin < config.yml +``` + +Device simulator runs as a pod within the desired cluster using the kubectl run command. The configuration of choice is provided via stdin of the simulator process within the pod, provided in the command above using `--stdin < config.yml`. Alternative names for a configuration file may be used -- the command simply uses stdin piping to provide simulator with an appropriate configuration. See the example YAML configuration below, with comments describing the various configurable fields. @@ -91,6 +93,31 @@ simulation: ``` +### Device Simulator on the Command Line + +#### Method 1 + +```sh +# With Golang installed, the device simulator can be run from the cmd folder. +cd ./cmd +go run . < config.yml +# Or by reading in a file instead of stdin: +# go run . --stdin=false --config=config.yml +``` + +#### Method 2 + +```sh +# With Golang installed, build a binary of the device simulator. +go build -o ./bin/device-simulator ./cmd +./device-simulator < config.yml + +# Or by reading in a file instead of stdin: +# ./device-simulator --stdin=false --config=config.yml +``` + +## Configuring a Simulation + ### Configuring Payload Formats There are currently five supported types of payload formats: @@ -178,7 +205,7 @@ Example Equations: ## Metrics -Prometheus metrics are provided by the krill simulator at the port specified in the metrics field of the configuration. The available metrics are: +Prometheus metrics are provided by the simulator at the port specified in the metrics field of the configuration. The available metrics are: -1. `krill_entity_gauge` - shows the count of each system entity. -1. `krill__asset_publish_counter` - records the number of messages published, labeled by asset identifier. \ No newline at end of file +1. `device_simulator_entity_gauge` - shows the count of each system entity. +1. `device_simulator__asset_publish_counter` - records the number of messages published, labeled by asset identifier. \ No newline at end of file diff --git a/samples/krill/cmd/krill/main.go b/samples/device-simulator/cmd/main.go similarity index 74% rename from samples/krill/cmd/krill/main.go rename to samples/device-simulator/cmd/main.go index dd7bbc9..7ee7022 100644 --- a/samples/krill/cmd/krill/main.go +++ b/samples/device-simulator/cmd/main.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package main import ( @@ -11,24 +14,24 @@ import ( "github.com/explore-iot-ops/lib/env" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/broker" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/edge" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/limiter" - "github.com/explore-iot-ops/samples/krill/components/node" - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/outlet" - "github.com/explore-iot-ops/samples/krill/components/provider" - "github.com/explore-iot-ops/samples/krill/components/publisher" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/renderer" - "github.com/explore-iot-ops/samples/krill/components/site" - "github.com/explore-iot-ops/samples/krill/components/subscriber" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/exporter" - "github.com/explore-iot-ops/samples/krill/lib/krill" + "github.com/explore-iot-ops/samples/device-simulator/components/broker" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/edge" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/limiter" + "github.com/explore-iot-ops/samples/device-simulator/components/node" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/outlet" + "github.com/explore-iot-ops/samples/device-simulator/components/provider" + "github.com/explore-iot-ops/samples/device-simulator/components/publisher" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/renderer" + "github.com/explore-iot-ops/samples/device-simulator/components/site" + "github.com/explore-iot-ops/samples/device-simulator/components/subscriber" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/exporter" + "github.com/explore-iot-ops/samples/device-simulator/lib/external" "gopkg.in/yaml.v3" "github.com/prometheus/client_golang/prometheus" @@ -45,7 +48,7 @@ func main() { func run() error { - fmt.Print(krill.Krill) + fmt.Print(external.Logo) ctx := context.Background() @@ -67,8 +70,8 @@ func run() error { unmarshal = json.Unmarshal } - configReader := env.New[krill.Configuration]( - func(cr *env.ConfigurationReader[krill.Configuration]) { + configReader := env.New[external.Configuration]( + func(cr *env.ConfigurationReader[external.Configuration]) { cr.Unmarshal = unmarshal if *flags["stdin"].(*bool) { cr.ReadFile = func(_ string) ([]byte, error) { @@ -186,7 +189,7 @@ func run() error { topicService := topic.NewService(topicStore, registryStore) tracerService := tracer.NewService(tracerStore, registryStore) - builder := krill.New( + builder := external.New( brokerService, clientService, edgeService, @@ -205,7 +208,7 @@ func run() error { tracerService, ) - lg.Printf("parsing krill configuration") + lg.Printf("parsing external configuration") err = builder.Parse(configuration.Simulation) if err != nil { diff --git a/samples/krill/components/broker/broker.go b/samples/device-simulator/components/broker/broker.go similarity index 84% rename from samples/krill/components/broker/broker.go rename to samples/device-simulator/components/broker/broker.go index af8e958..2afddf6 100644 --- a/samples/krill/components/broker/broker.go +++ b/samples/device-simulator/components/broker/broker.go @@ -1,10 +1,13 @@ -// Package broker provides the implementation of the broker component of the simulation framework. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package broker provides the implementation of the broker component of the simulation framework. package broker import ( "fmt" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" ) type Source interface { diff --git a/samples/krill/components/broker/broker_test.go b/samples/device-simulator/components/broker/broker_test.go similarity index 86% rename from samples/krill/components/broker/broker_test.go rename to samples/device-simulator/components/broker/broker_test.go index 0f694a9..f46391a 100644 --- a/samples/krill/components/broker/broker_test.go +++ b/samples/device-simulator/components/broker/broker_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package broker import ( diff --git a/samples/krill/components/broker/service.go b/samples/device-simulator/components/broker/service.go similarity index 73% rename from samples/krill/components/broker/service.go rename to samples/device-simulator/components/broker/service.go index 4075e92..b4eedc6 100644 --- a/samples/krill/components/broker/service.go +++ b/samples/device-simulator/components/broker/service.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package broker import ( - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[Source, component.ID] diff --git a/samples/krill/components/broker/service_test.go b/samples/device-simulator/components/broker/service_test.go similarity index 87% rename from samples/krill/components/broker/service_test.go rename to samples/device-simulator/components/broker/service_test.go index a55d3e2..78d1e78 100644 --- a/samples/krill/components/broker/service_test.go +++ b/samples/device-simulator/components/broker/service_test.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package broker import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/client/client.go b/samples/device-simulator/components/client/client.go similarity index 97% rename from samples/krill/components/client/client.go rename to samples/device-simulator/components/client/client.go index bd589f0..b7eb66d 100644 --- a/samples/krill/components/client/client.go +++ b/samples/device-simulator/components/client/client.go @@ -1,4 +1,7 @@ -// Package client contains all MQTT client interfaces and implementations. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package client contains all MQTT client interfaces and implementations. // It defines several client implementations, including MQTT v3 and v5 compatible clients // as well as mocking clients for testing. package client @@ -9,8 +12,8 @@ import ( "time" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/site" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/site" mqtt "github.com/eclipse/paho.mqtt.golang" ) diff --git a/samples/krill/components/client/client_test.go b/samples/device-simulator/components/client/client_test.go similarity index 98% rename from samples/krill/components/client/client_test.go rename to samples/device-simulator/components/client/client_test.go index 0d17cf0..a80484e 100644 --- a/samples/krill/components/client/client_test.go +++ b/samples/device-simulator/components/client/client_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package client import ( @@ -7,8 +10,8 @@ import ( mqttv5 "github.com/eclipse/paho.golang/paho" mqtt "github.com/eclipse/paho.mqtt.golang" - "github.com/explore-iot-ops/samples/krill/components/site" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/components/site" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/client/clientv5.go b/samples/device-simulator/components/client/clientv5.go similarity index 99% rename from samples/krill/components/client/clientv5.go rename to samples/device-simulator/components/client/clientv5.go index af48e4c..57ae4ac 100644 --- a/samples/krill/components/client/clientv5.go +++ b/samples/device-simulator/components/client/clientv5.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package client import ( diff --git a/samples/krill/components/client/errors.go b/samples/device-simulator/components/client/errors.go similarity index 79% rename from samples/krill/components/client/errors.go rename to samples/device-simulator/components/client/errors.go index 9c8daaa..75f289b 100644 --- a/samples/krill/components/client/errors.go +++ b/samples/device-simulator/components/client/errors.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package client import ( "fmt" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" ) type BrokerConnectionError struct { diff --git a/samples/krill/components/client/service.go b/samples/device-simulator/components/client/service.go similarity index 85% rename from samples/krill/components/client/service.go rename to samples/device-simulator/components/client/service.go index f2484e1..8b7454c 100644 --- a/samples/krill/components/client/service.go +++ b/samples/device-simulator/components/client/service.go @@ -1,15 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package client import ( "context" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/broker" - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/site" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/dialer" + "github.com/explore-iot-ops/samples/device-simulator/components/broker" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/site" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/dialer" mqttv5 "github.com/eclipse/paho.golang/paho" mqttv3 "github.com/eclipse/paho.mqtt.golang" diff --git a/samples/krill/components/client/service_test.go b/samples/device-simulator/components/client/service_test.go similarity index 96% rename from samples/krill/components/client/service_test.go rename to samples/device-simulator/components/client/service_test.go index e6d832c..857e949 100644 --- a/samples/krill/components/client/service_test.go +++ b/samples/device-simulator/components/client/service_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package client import ( @@ -5,11 +8,11 @@ import ( "net" "testing" - "github.com/explore-iot-ops/samples/krill/components/broker" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/site" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/dialer" + "github.com/explore-iot-ops/samples/device-simulator/components/broker" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/site" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/dialer" "github.com/stretchr/testify/require" mqttv5 "github.com/eclipse/paho.golang/paho" diff --git a/samples/krill/components/edge/edge_test.go b/samples/device-simulator/components/edge/edge_test.go similarity index 96% rename from samples/krill/components/edge/edge_test.go rename to samples/device-simulator/components/edge/edge_test.go index d3dd3d6..aed9a3b 100644 --- a/samples/krill/components/edge/edge_test.go +++ b/samples/device-simulator/components/edge/edge_test.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package edge import ( "testing" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/edge/errors.go b/samples/device-simulator/components/edge/errors.go similarity index 87% rename from samples/krill/components/edge/errors.go rename to samples/device-simulator/components/edge/errors.go index 19a7943..8678894 100644 --- a/samples/krill/components/edge/errors.go +++ b/samples/device-simulator/components/edge/errors.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package edge import ( "fmt" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" ) type InvalidPositionError struct { diff --git a/samples/krill/components/edge/service.go b/samples/device-simulator/components/edge/service.go similarity index 85% rename from samples/krill/components/edge/service.go rename to samples/device-simulator/components/edge/service.go index 1d0490a..038e5f2 100644 --- a/samples/krill/components/edge/service.go +++ b/samples/device-simulator/components/edge/service.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package edge import ( - "github.com/explore-iot-ops/samples/krill/components/node" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/components/node" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" ) type Store component.Store[composition.Edge, component.ID] diff --git a/samples/krill/components/formatter/errors.go b/samples/device-simulator/components/formatter/errors.go similarity index 68% rename from samples/krill/components/formatter/errors.go rename to samples/device-simulator/components/formatter/errors.go index ad65f28..0100103 100644 --- a/samples/krill/components/formatter/errors.go +++ b/samples/device-simulator/components/formatter/errors.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package formatter import ( "fmt" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" ) type InvalidTypeError struct { diff --git a/samples/krill/components/formatter/formatter.go b/samples/device-simulator/components/formatter/formatter.go similarity index 93% rename from samples/krill/components/formatter/formatter.go rename to samples/device-simulator/components/formatter/formatter.go index c129606..81c443a 100644 --- a/samples/krill/components/formatter/formatter.go +++ b/samples/device-simulator/components/formatter/formatter.go @@ -1,4 +1,7 @@ -// Package formatter provides the implementation of the formatter component of the simulation framework. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package formatter provides the implementation of the formatter component of the simulation framework. package formatter import ( @@ -9,8 +12,8 @@ import ( "io" protoEncoder "github.com/explore-iot-ops/lib/proto" - binaryEncoder "github.com/explore-iot-ops/samples/krill/lib/binary" - "github.com/explore-iot-ops/samples/krill/lib/flatten" + binaryEncoder "github.com/explore-iot-ops/samples/device-simulator/lib/binary" + "github.com/explore-iot-ops/samples/device-simulator/lib/flatten" "google.golang.org/protobuf/proto" ) diff --git a/samples/krill/components/formatter/formatter_test.go b/samples/device-simulator/components/formatter/formatter_test.go similarity index 94% rename from samples/krill/components/formatter/formatter_test.go rename to samples/device-simulator/components/formatter/formatter_test.go index 12e92e8..5a3f943 100644 --- a/samples/krill/components/formatter/formatter_test.go +++ b/samples/device-simulator/components/formatter/formatter_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package formatter import ( @@ -6,8 +9,8 @@ import ( "testing" "github.com/explore-iot-ops/lib/proto" - "github.com/explore-iot-ops/samples/krill/lib/binary" - "github.com/explore-iot-ops/samples/krill/lib/flatten" + "github.com/explore-iot-ops/samples/device-simulator/lib/binary" + "github.com/explore-iot-ops/samples/device-simulator/lib/flatten" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/formatter/service.go b/samples/device-simulator/components/formatter/service.go similarity index 80% rename from samples/krill/components/formatter/service.go rename to samples/device-simulator/components/formatter/service.go index 50df0c4..11ad5f5 100644 --- a/samples/krill/components/formatter/service.go +++ b/samples/device-simulator/components/formatter/service.go @@ -1,12 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package formatter import ( "encoding/binary" "github.com/explore-iot-ops/lib/proto" - encoder "github.com/explore-iot-ops/samples/krill/lib/binary" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/flatten" + encoder "github.com/explore-iot-ops/samples/device-simulator/lib/binary" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/flatten" ) type Store component.Store[Formatter, component.ID] diff --git a/samples/krill/components/formatter/service_test.go b/samples/device-simulator/components/formatter/service_test.go similarity index 94% rename from samples/krill/components/formatter/service_test.go rename to samples/device-simulator/components/formatter/service_test.go index 283221f..8f3918c 100644 --- a/samples/krill/components/formatter/service_test.go +++ b/samples/device-simulator/components/formatter/service_test.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package formatter import ( "testing" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/limiter/errors.go b/samples/device-simulator/components/limiter/errors.go similarity index 78% rename from samples/krill/components/limiter/errors.go rename to samples/device-simulator/components/limiter/errors.go index c78be5f..58a5fd3 100644 --- a/samples/krill/components/limiter/errors.go +++ b/samples/device-simulator/components/limiter/errors.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package limiter import ( "fmt" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" ) type InvalidLimitError struct { diff --git a/samples/krill/components/limiter/limiter.go b/samples/device-simulator/components/limiter/limiter.go similarity index 96% rename from samples/krill/components/limiter/limiter.go rename to samples/device-simulator/components/limiter/limiter.go index bcc2693..24c0a71 100755 --- a/samples/krill/components/limiter/limiter.go +++ b/samples/device-simulator/components/limiter/limiter.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package limiter import ( diff --git a/samples/krill/components/limiter/limiter_test.go b/samples/device-simulator/components/limiter/limiter_test.go similarity index 94% rename from samples/krill/components/limiter/limiter_test.go rename to samples/device-simulator/components/limiter/limiter_test.go index d93f07d..84a2714 100755 --- a/samples/krill/components/limiter/limiter_test.go +++ b/samples/device-simulator/components/limiter/limiter_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package limiter import ( diff --git a/samples/krill/components/limiter/service.go b/samples/device-simulator/components/limiter/service.go similarity index 85% rename from samples/krill/components/limiter/service.go rename to samples/device-simulator/components/limiter/service.go index f9ef38b..14a0651 100644 --- a/samples/krill/components/limiter/service.go +++ b/samples/device-simulator/components/limiter/service.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package limiter import ( "context" "time" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[Limiter[struct{}], component.ID] diff --git a/samples/krill/components/limiter/service_test.go b/samples/device-simulator/components/limiter/service_test.go similarity index 91% rename from samples/krill/components/limiter/service_test.go rename to samples/device-simulator/components/limiter/service_test.go index 4cc7e76..ea3693d 100644 --- a/samples/krill/components/limiter/service_test.go +++ b/samples/device-simulator/components/limiter/service_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package limiter import ( @@ -5,7 +8,7 @@ import ( "testing" "time" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/node/errors.go b/samples/device-simulator/components/node/errors.go similarity index 80% rename from samples/krill/components/node/errors.go rename to samples/device-simulator/components/node/errors.go index 200711e..d71b75a 100644 --- a/samples/krill/components/node/errors.go +++ b/samples/device-simulator/components/node/errors.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package node import ( "fmt" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" ) type InvalidConfigurationError struct { diff --git a/samples/krill/components/node/node_test.go b/samples/device-simulator/components/node/node_test.go similarity index 91% rename from samples/krill/components/node/node_test.go rename to samples/device-simulator/components/node/node_test.go index 20f4761..fefaf8b 100644 --- a/samples/krill/components/node/node_test.go +++ b/samples/device-simulator/components/node/node_test.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package node import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/node/service.go b/samples/device-simulator/components/node/service.go similarity index 81% rename from samples/krill/components/node/service.go rename to samples/device-simulator/components/node/service.go index b6041dd..1c936a4 100644 --- a/samples/krill/components/node/service.go +++ b/samples/device-simulator/components/node/service.go @@ -1,12 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package node import ( "go/parser" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/composition" - "github.com/explore-iot-ops/samples/krill/lib/expression" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/lib/expression" ) type Store component.Store[composition.Renderer, component.ID] diff --git a/samples/krill/components/observer/observer.go b/samples/device-simulator/components/observer/observer.go similarity index 89% rename from samples/krill/components/observer/observer.go rename to samples/device-simulator/components/observer/observer.go index 4e71a0d..436fa22 100644 --- a/samples/krill/components/observer/observer.go +++ b/samples/device-simulator/components/observer/observer.go @@ -1,7 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package observer import ( - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" ) // Observer is an implementation of the CancellableObservable interface and serves as the observer component in the simulation framework. diff --git a/samples/krill/components/observer/observer_test.go b/samples/device-simulator/components/observer/observer_test.go similarity index 90% rename from samples/krill/components/observer/observer_test.go rename to samples/device-simulator/components/observer/observer_test.go index 4a4b256..9f7a206 100644 --- a/samples/krill/components/observer/observer_test.go +++ b/samples/device-simulator/components/observer/observer_test.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package observer import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/observer/service.go b/samples/device-simulator/components/observer/service.go similarity index 75% rename from samples/krill/components/observer/service.go rename to samples/device-simulator/components/observer/service.go index 4a14d43..23485f9 100644 --- a/samples/krill/components/observer/service.go +++ b/samples/device-simulator/components/observer/service.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package observer import ( - "github.com/explore-iot-ops/samples/krill/components/provider" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/provider" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[*Observer, component.ID] diff --git a/samples/krill/components/observer/service_test.go b/samples/device-simulator/components/observer/service_test.go similarity index 92% rename from samples/krill/components/observer/service_test.go rename to samples/device-simulator/components/observer/service_test.go index beba2dd..41c79e0 100644 --- a/samples/krill/components/observer/service_test.go +++ b/samples/device-simulator/components/observer/service_test.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package observer import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/provider" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/provider" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/outlet/outlet.go b/samples/device-simulator/components/outlet/outlet.go similarity index 80% rename from samples/krill/components/outlet/outlet.go rename to samples/device-simulator/components/outlet/outlet.go index c657964..4ca4691 100644 --- a/samples/krill/components/outlet/outlet.go +++ b/samples/device-simulator/components/outlet/outlet.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package outlet import ( "errors" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/expression" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/expression" ) var ( diff --git a/samples/krill/components/outlet/outlet_test.go b/samples/device-simulator/components/outlet/outlet_test.go similarity index 86% rename from samples/krill/components/outlet/outlet_test.go rename to samples/device-simulator/components/outlet/outlet_test.go index 286ff59..3b97162 100644 --- a/samples/krill/components/outlet/outlet_test.go +++ b/samples/device-simulator/components/outlet/outlet_test.go @@ -1,12 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package outlet import ( "errors" "testing" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/expression" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/expression" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/outlet/service.go b/samples/device-simulator/components/outlet/service.go similarity index 74% rename from samples/krill/components/outlet/service.go rename to samples/device-simulator/components/outlet/service.go index 91bee2f..0c15238 100644 --- a/samples/krill/components/outlet/service.go +++ b/samples/device-simulator/components/outlet/service.go @@ -1,12 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package outlet import ( "go/parser" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/expression" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/expression" ) type Store component.Store[Outlet, component.ID] diff --git a/samples/krill/components/outlet/service_test.go b/samples/device-simulator/components/outlet/service_test.go similarity index 90% rename from samples/krill/components/outlet/service_test.go rename to samples/device-simulator/components/outlet/service_test.go index 14701cb..cc3a9a6 100644 --- a/samples/krill/components/outlet/service_test.go +++ b/samples/device-simulator/components/outlet/service_test.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package outlet import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/provider/errors.go b/samples/device-simulator/components/provider/errors.go similarity index 70% rename from samples/krill/components/provider/errors.go rename to samples/device-simulator/components/provider/errors.go index 0dd97d4..79bfc07 100644 --- a/samples/krill/components/provider/errors.go +++ b/samples/device-simulator/components/provider/errors.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package provider import ( "fmt" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" ) type InvalidTypeError struct { diff --git a/samples/krill/components/provider/provider.go b/samples/device-simulator/components/provider/provider.go similarity index 88% rename from samples/krill/components/provider/provider.go rename to samples/device-simulator/components/provider/provider.go index 0255cfd..bba29af 100644 --- a/samples/krill/components/provider/provider.go +++ b/samples/device-simulator/components/provider/provider.go @@ -1,7 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package provider import ( - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" "github.com/prometheus/client_golang/prometheus" ) diff --git a/samples/krill/components/provider/provider_test.go b/samples/device-simulator/components/provider/provider_test.go similarity index 78% rename from samples/krill/components/provider/provider_test.go rename to samples/device-simulator/components/provider/provider_test.go index ab124e7..23fbaa7 100644 --- a/samples/krill/components/provider/provider_test.go +++ b/samples/device-simulator/components/provider/provider_test.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package provider import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/provider/service.go b/samples/device-simulator/components/provider/service.go similarity index 83% rename from samples/krill/components/provider/service.go rename to samples/device-simulator/components/provider/service.go index 79848ee..9106a2c 100644 --- a/samples/krill/components/provider/service.go +++ b/samples/device-simulator/components/provider/service.go @@ -1,12 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package provider import ( "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/counter" - "github.com/explore-iot-ops/samples/krill/lib/exporter" - "github.com/explore-iot-ops/samples/krill/lib/gauge" - "github.com/explore-iot-ops/samples/krill/lib/histogram" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/counter" + "github.com/explore-iot-ops/samples/device-simulator/lib/exporter" + "github.com/explore-iot-ops/samples/device-simulator/lib/gauge" + "github.com/explore-iot-ops/samples/device-simulator/lib/histogram" "github.com/prometheus/client_golang/prometheus" ) diff --git a/samples/krill/components/provider/service_test.go b/samples/device-simulator/components/provider/service_test.go similarity index 92% rename from samples/krill/components/provider/service_test.go rename to samples/device-simulator/components/provider/service_test.go index 46d7b88..50512e1 100644 --- a/samples/krill/components/provider/service_test.go +++ b/samples/device-simulator/components/provider/service_test.go @@ -1,14 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package provider import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/counter" - "github.com/explore-iot-ops/samples/krill/lib/exporter" - "github.com/explore-iot-ops/samples/krill/lib/gauge" - "github.com/explore-iot-ops/samples/krill/lib/histogram" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/counter" + "github.com/explore-iot-ops/samples/device-simulator/lib/exporter" + "github.com/explore-iot-ops/samples/device-simulator/lib/gauge" + "github.com/explore-iot-ops/samples/device-simulator/lib/histogram" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/publisher/publisher.go b/samples/device-simulator/components/publisher/publisher.go similarity index 84% rename from samples/krill/components/publisher/publisher.go rename to samples/device-simulator/components/publisher/publisher.go index 875a8cc..4484eab 100644 --- a/samples/krill/components/publisher/publisher.go +++ b/samples/device-simulator/components/publisher/publisher.go @@ -1,4 +1,7 @@ -// Package publisher provides the implementation for the publisher component of the simulation framework along with all associated interfaces. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package publisher provides the implementation for the publisher component of the simulation framework along with all associated interfaces. package publisher import ( @@ -6,13 +9,13 @@ import ( "time" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/limiter" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/renderer" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/environment" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/limiter" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/renderer" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/environment" ) // Publisher is a component which routinely publishes messages on a provided topic name. diff --git a/samples/krill/components/publisher/publisher_test.go b/samples/device-simulator/components/publisher/publisher_test.go similarity index 81% rename from samples/krill/components/publisher/publisher_test.go rename to samples/device-simulator/components/publisher/publisher_test.go index dbaae34..62d9b1d 100644 --- a/samples/krill/components/publisher/publisher_test.go +++ b/samples/device-simulator/components/publisher/publisher_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package publisher import ( @@ -5,16 +8,16 @@ import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/limiter" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/renderer" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/composition" - "github.com/explore-iot-ops/samples/krill/lib/environment" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/limiter" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/renderer" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/lib/environment" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/publisher/service.go b/samples/device-simulator/components/publisher/service.go similarity index 77% rename from samples/krill/components/publisher/service.go rename to samples/device-simulator/components/publisher/service.go index da99b07..8eef619 100644 --- a/samples/krill/components/publisher/service.go +++ b/samples/device-simulator/components/publisher/service.go @@ -1,18 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package publisher import ( "context" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/limiter" - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/renderer" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/environment" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/limiter" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/renderer" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/environment" ) type Store component.Store[*Publisher, component.ID] diff --git a/samples/krill/components/publisher/service_test.go b/samples/device-simulator/components/publisher/service_test.go similarity index 93% rename from samples/krill/components/publisher/service_test.go rename to samples/device-simulator/components/publisher/service_test.go index dc1a989..863d442 100644 --- a/samples/krill/components/publisher/service_test.go +++ b/samples/device-simulator/components/publisher/service_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package publisher import ( @@ -5,13 +8,13 @@ import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/limiter" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/renderer" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/limiter" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/renderer" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/registry/registry.go b/samples/device-simulator/components/registry/registry.go similarity index 94% rename from samples/krill/components/registry/registry.go rename to samples/device-simulator/components/registry/registry.go index 97eb170..8a5d81c 100644 --- a/samples/krill/components/registry/registry.go +++ b/samples/device-simulator/components/registry/registry.go @@ -1,4 +1,7 @@ -// Package registry contains the implementation of the monitor and observer components as well as other functionality related to configurable metrics and observability. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package registry contains the implementation of the monitor and observer components as well as other functionality related to configurable metrics and observability. package registry import "sync" diff --git a/samples/krill/components/registry/registry_test.go b/samples/device-simulator/components/registry/registry_test.go similarity index 93% rename from samples/krill/components/registry/registry_test.go rename to samples/device-simulator/components/registry/registry_test.go index 909c714..ec5c273 100644 --- a/samples/krill/components/registry/registry_test.go +++ b/samples/device-simulator/components/registry/registry_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package registry import ( diff --git a/samples/krill/components/registry/service.go b/samples/device-simulator/components/registry/service.go similarity index 75% rename from samples/krill/components/registry/service.go rename to samples/device-simulator/components/registry/service.go index 5a4a553..fac7618 100644 --- a/samples/krill/components/registry/service.go +++ b/samples/device-simulator/components/registry/service.go @@ -1,7 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package registry import ( - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[ObservableRegistry, component.ID] diff --git a/samples/krill/components/registry/service_test.go b/samples/device-simulator/components/registry/service_test.go similarity index 79% rename from samples/krill/components/registry/service_test.go rename to samples/device-simulator/components/registry/service_test.go index 71e4323..7088fcc 100644 --- a/samples/krill/components/registry/service_test.go +++ b/samples/device-simulator/components/registry/service_test.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package registry import ( "testing" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/renderer/renderer.go b/samples/device-simulator/components/renderer/renderer.go similarity index 70% rename from samples/krill/components/renderer/renderer.go rename to samples/device-simulator/components/renderer/renderer.go index 9135203..3b6dfee 100644 --- a/samples/krill/components/renderer/renderer.go +++ b/samples/device-simulator/components/renderer/renderer.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package renderer import ( - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/lib/composition" - "github.com/explore-iot-ops/samples/krill/lib/environment" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/lib/environment" ) type Renderer interface { diff --git a/samples/krill/components/renderer/renderer_test.go b/samples/device-simulator/components/renderer/renderer_test.go similarity index 73% rename from samples/krill/components/renderer/renderer_test.go rename to samples/device-simulator/components/renderer/renderer_test.go index b8c683a..a68f1eb 100644 --- a/samples/krill/components/renderer/renderer_test.go +++ b/samples/device-simulator/components/renderer/renderer_test.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package renderer import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/lib/composition" - "github.com/explore-iot-ops/samples/krill/lib/environment" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/lib/environment" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/renderer/service.go b/samples/device-simulator/components/renderer/service.go similarity index 74% rename from samples/krill/components/renderer/service.go rename to samples/device-simulator/components/renderer/service.go index fe22d9d..201cef4 100644 --- a/samples/krill/components/renderer/service.go +++ b/samples/device-simulator/components/renderer/service.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package renderer import ( - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/node" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/node" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[Renderer, component.ID] diff --git a/samples/krill/components/renderer/service_test.go b/samples/device-simulator/components/renderer/service_test.go similarity index 88% rename from samples/krill/components/renderer/service_test.go rename to samples/device-simulator/components/renderer/service_test.go index 801cd8e..d03434c 100644 --- a/samples/krill/components/renderer/service_test.go +++ b/samples/device-simulator/components/renderer/service_test.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package renderer import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/composition" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/composition" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/site/service.go b/samples/device-simulator/components/site/service.go similarity index 73% rename from samples/krill/components/site/service.go rename to samples/device-simulator/components/site/service.go index 7ce175e..6878968 100644 --- a/samples/krill/components/site/service.go +++ b/samples/device-simulator/components/site/service.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package site import ( - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[Site, component.ID] diff --git a/samples/krill/components/site/service_test.go b/samples/device-simulator/components/site/service_test.go similarity index 90% rename from samples/krill/components/site/service_test.go rename to samples/device-simulator/components/site/service_test.go index 065c52c..18a283e 100644 --- a/samples/krill/components/site/service_test.go +++ b/samples/device-simulator/components/site/service_test.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package site import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/site/site.go b/samples/device-simulator/components/site/site.go similarity index 79% rename from samples/krill/components/site/site.go rename to samples/device-simulator/components/site/site.go index 5ef2f99..b9e14ff 100644 --- a/samples/krill/components/site/site.go +++ b/samples/device-simulator/components/site/site.go @@ -1,7 +1,10 @@ -// Package site provides the implementation of the site component of the simulation framework. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package site provides the implementation of the site component of the simulation framework. package site -import "github.com/explore-iot-ops/samples/krill/components/registry" +import "github.com/explore-iot-ops/samples/device-simulator/components/registry" type Site interface { Render() string diff --git a/samples/krill/components/site/site_test.go b/samples/device-simulator/components/site/site_test.go similarity index 72% rename from samples/krill/components/site/site_test.go rename to samples/device-simulator/components/site/site_test.go index 38b8097..28d8b8b 100644 --- a/samples/krill/components/site/site_test.go +++ b/samples/device-simulator/components/site/site_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package site import ( diff --git a/samples/krill/components/subscriber/service.go b/samples/device-simulator/components/subscriber/service.go similarity index 79% rename from samples/krill/components/subscriber/service.go rename to samples/device-simulator/components/subscriber/service.go index efd78d4..988a144 100644 --- a/samples/krill/components/subscriber/service.go +++ b/samples/device-simulator/components/subscriber/service.go @@ -1,14 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package subscriber import ( "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/outlet" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/outlet" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[*Subscriber, component.ID] diff --git a/samples/krill/components/subscriber/service_test.go b/samples/device-simulator/components/subscriber/service_test.go similarity index 94% rename from samples/krill/components/subscriber/service_test.go rename to samples/device-simulator/components/subscriber/service_test.go index d1b2514..4553749 100644 --- a/samples/krill/components/subscriber/service_test.go +++ b/samples/device-simulator/components/subscriber/service_test.go @@ -1,15 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package subscriber import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/outlet" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/outlet" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/subscriber/subscriber.go b/samples/device-simulator/components/subscriber/subscriber.go similarity index 84% rename from samples/krill/components/subscriber/subscriber.go rename to samples/device-simulator/components/subscriber/subscriber.go index 9213e1a..88bcc00 100644 --- a/samples/krill/components/subscriber/subscriber.go +++ b/samples/device-simulator/components/subscriber/subscriber.go @@ -1,15 +1,18 @@ -// Package subscriber provides the implementation for the subscriber component of the simulation framework. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package subscriber provides the implementation for the subscriber component of the simulation framework. package subscriber import ( "fmt" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/outlet" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/outlet" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" ) type ClientConnectionClosedError struct { diff --git a/samples/krill/components/subscriber/subscriber_test.go b/samples/device-simulator/components/subscriber/subscriber_test.go similarity index 89% rename from samples/krill/components/subscriber/subscriber_test.go rename to samples/device-simulator/components/subscriber/subscriber_test.go index aa64eae..6fcf668 100644 --- a/samples/krill/components/subscriber/subscriber_test.go +++ b/samples/device-simulator/components/subscriber/subscriber_test.go @@ -1,13 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package subscriber import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/outlet" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/outlet" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/topic/service.go b/samples/device-simulator/components/topic/service.go similarity index 73% rename from samples/krill/components/topic/service.go rename to samples/device-simulator/components/topic/service.go index b97c621..b5c2faf 100644 --- a/samples/krill/components/topic/service.go +++ b/samples/device-simulator/components/topic/service.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package topic import ( - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[Renderer, component.ID] diff --git a/samples/krill/components/topic/service_test.go b/samples/device-simulator/components/topic/service_test.go similarity index 90% rename from samples/krill/components/topic/service_test.go rename to samples/device-simulator/components/topic/service_test.go index bc463b3..7768416 100644 --- a/samples/krill/components/topic/service_test.go +++ b/samples/device-simulator/components/topic/service_test.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package topic import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/topic/topic.go b/samples/device-simulator/components/topic/topic.go similarity index 80% rename from samples/krill/components/topic/topic.go rename to samples/device-simulator/components/topic/topic.go index b790c21..10b6dd3 100644 --- a/samples/krill/components/topic/topic.go +++ b/samples/device-simulator/components/topic/topic.go @@ -1,8 +1,11 @@ -// Package topic provides the implementation for the topic component of the simulation framework. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package topic provides the implementation for the topic component of the simulation framework. package topic import ( - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" ) // Renderer is an interface whose implementation should be able to render a topic name when called and should also implement the registry observable interface. diff --git a/samples/krill/components/topic/topic_test.go b/samples/device-simulator/components/topic/topic_test.go similarity index 84% rename from samples/krill/components/topic/topic_test.go rename to samples/device-simulator/components/topic/topic_test.go index bb70409..912daec 100644 --- a/samples/krill/components/topic/topic_test.go +++ b/samples/device-simulator/components/topic/topic_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package topic import ( diff --git a/samples/krill/components/tracer/service.go b/samples/device-simulator/components/tracer/service.go similarity index 77% rename from samples/krill/components/tracer/service.go rename to samples/device-simulator/components/tracer/service.go index 94abf77..a98393d 100644 --- a/samples/krill/components/tracer/service.go +++ b/samples/device-simulator/components/tracer/service.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package tracer import ( "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" ) type Store component.Store[Tracer, component.ID] diff --git a/samples/krill/components/tracer/service_test.go b/samples/device-simulator/components/tracer/service_test.go similarity index 90% rename from samples/krill/components/tracer/service_test.go rename to samples/device-simulator/components/tracer/service_test.go index 4bed4f1..10c1db8 100644 --- a/samples/krill/components/tracer/service_test.go +++ b/samples/device-simulator/components/tracer/service_test.go @@ -1,11 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package tracer import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/components/tracer/tracer.go b/samples/device-simulator/components/tracer/tracer.go similarity index 89% rename from samples/krill/components/tracer/tracer.go rename to samples/device-simulator/components/tracer/tracer.go index 2f95c25..cb4674e 100644 --- a/samples/krill/components/tracer/tracer.go +++ b/samples/device-simulator/components/tracer/tracer.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package tracer import ( @@ -5,7 +8,7 @@ import ( "time" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" ) type Tracer interface { diff --git a/samples/krill/components/tracer/tracer_test.go b/samples/device-simulator/components/tracer/tracer_test.go similarity index 84% rename from samples/krill/components/tracer/tracer_test.go rename to samples/device-simulator/components/tracer/tracer_test.go index e61f24d..4b6c017 100644 --- a/samples/krill/components/tracer/tracer_test.go +++ b/samples/device-simulator/components/tracer/tracer_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package tracer import ( @@ -5,7 +8,7 @@ import ( "time" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/configs/simple/config.yml b/samples/device-simulator/configs/simple/config.yml similarity index 100% rename from samples/krill/configs/simple/config.yml rename to samples/device-simulator/configs/simple/config.yml diff --git a/samples/krill/go.mod b/samples/device-simulator/go.mod similarity index 97% rename from samples/krill/go.mod rename to samples/device-simulator/go.mod index 386e217..a69ba59 100644 --- a/samples/krill/go.mod +++ b/samples/device-simulator/go.mod @@ -1,4 +1,4 @@ -module github.com/explore-iot-ops/samples/krill +module github.com/explore-iot-ops/samples/device-simulator go 1.21.3 diff --git a/samples/krill/go.sum b/samples/device-simulator/go.sum similarity index 100% rename from samples/krill/go.sum rename to samples/device-simulator/go.sum diff --git a/samples/krill/lib/binary/binary.go b/samples/device-simulator/lib/binary/binary.go similarity index 94% rename from samples/krill/lib/binary/binary.go rename to samples/device-simulator/lib/binary/binary.go index e675fc6..637c84e 100644 --- a/samples/krill/lib/binary/binary.go +++ b/samples/device-simulator/lib/binary/binary.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package binary import ( diff --git a/samples/krill/lib/binary/binary_test.go b/samples/device-simulator/lib/binary/binary_test.go similarity index 95% rename from samples/krill/lib/binary/binary_test.go rename to samples/device-simulator/lib/binary/binary_test.go index 45752a3..09eee3f 100644 --- a/samples/krill/lib/binary/binary_test.go +++ b/samples/device-simulator/lib/binary/binary_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package binary import ( diff --git a/samples/krill/lib/component/component.go b/samples/device-simulator/lib/component/component.go similarity index 81% rename from samples/krill/lib/component/component.go rename to samples/device-simulator/lib/component/component.go index 925b347..4751e0d 100644 --- a/samples/krill/lib/component/component.go +++ b/samples/device-simulator/lib/component/component.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package component type ( diff --git a/samples/krill/lib/component/component_test.go b/samples/device-simulator/lib/component/component_test.go similarity index 95% rename from samples/krill/lib/component/component_test.go rename to samples/device-simulator/lib/component/component_test.go index 14388a2..e2deb66 100644 --- a/samples/krill/lib/component/component_test.go +++ b/samples/device-simulator/lib/component/component_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package component import ( diff --git a/samples/krill/lib/component/errors.go b/samples/device-simulator/lib/component/errors.go similarity index 59% rename from samples/krill/lib/component/errors.go rename to samples/device-simulator/lib/component/errors.go index 2f9b541..6d1d323 100644 --- a/samples/krill/lib/component/errors.go +++ b/samples/device-simulator/lib/component/errors.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package component type NotFoundError struct{} diff --git a/samples/krill/lib/component/mock.go b/samples/device-simulator/lib/component/mock.go similarity index 93% rename from samples/krill/lib/component/mock.go rename to samples/device-simulator/lib/component/mock.go index d054733..8fec4a3 100644 --- a/samples/krill/lib/component/mock.go +++ b/samples/device-simulator/lib/component/mock.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package component type ( diff --git a/samples/krill/lib/component/store.go b/samples/device-simulator/lib/component/store.go similarity index 94% rename from samples/krill/lib/component/store.go rename to samples/device-simulator/lib/component/store.go index 04d9081..d8f305c 100644 --- a/samples/krill/lib/component/store.go +++ b/samples/device-simulator/lib/component/store.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package component import ( diff --git a/samples/krill/lib/component/store_test.go b/samples/device-simulator/lib/component/store_test.go similarity index 95% rename from samples/krill/lib/component/store_test.go rename to samples/device-simulator/lib/component/store_test.go index 469d447..62fc4c8 100644 --- a/samples/krill/lib/component/store_test.go +++ b/samples/device-simulator/lib/component/store_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package component import ( diff --git a/samples/krill/lib/composition/composition.go b/samples/device-simulator/lib/composition/composition.go similarity index 95% rename from samples/krill/lib/composition/composition.go rename to samples/device-simulator/lib/composition/composition.go index a691570..a6331f0 100644 --- a/samples/krill/lib/composition/composition.go +++ b/samples/device-simulator/lib/composition/composition.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package composition import ( "sort" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/lib/expression" + "github.com/explore-iot-ops/samples/device-simulator/lib/expression" ) const ( diff --git a/samples/krill/lib/composition/composition_test.go b/samples/device-simulator/lib/composition/composition_test.go similarity index 94% rename from samples/krill/lib/composition/composition_test.go rename to samples/device-simulator/lib/composition/composition_test.go index c0f5c9b..f4862e1 100644 --- a/samples/krill/lib/composition/composition_test.go +++ b/samples/device-simulator/lib/composition/composition_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package composition import ( @@ -5,7 +8,7 @@ import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/lib/expression" + "github.com/explore-iot-ops/samples/device-simulator/lib/expression" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/lib/composition/mock.go b/samples/device-simulator/lib/composition/mock.go similarity index 84% rename from samples/krill/lib/composition/mock.go rename to samples/device-simulator/lib/composition/mock.go index 7a5d162..a48a5cc 100644 --- a/samples/krill/lib/composition/mock.go +++ b/samples/device-simulator/lib/composition/mock.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package composition type MockRenderer struct { diff --git a/samples/krill/lib/counter/counter.go b/samples/device-simulator/lib/counter/counter.go similarity index 93% rename from samples/krill/lib/counter/counter.go rename to samples/device-simulator/lib/counter/counter.go index 652b90b..412a96c 100644 --- a/samples/krill/lib/counter/counter.go +++ b/samples/device-simulator/lib/counter/counter.go @@ -1,12 +1,15 @@ -// Package counter contains the counter-based implementations of a Provider. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package counter contains the counter-based implementations of a Provider. // Counter Providers represent and wrap the counterVec prometheus metrics. package counter import ( "fmt" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" "github.com/prometheus/client_golang/prometheus" ) diff --git a/samples/krill/lib/counter/counter_test.go b/samples/device-simulator/lib/counter/counter_test.go similarity index 96% rename from samples/krill/lib/counter/counter_test.go rename to samples/device-simulator/lib/counter/counter_test.go index 583fc7e..994c580 100644 --- a/samples/krill/lib/counter/counter_test.go +++ b/samples/device-simulator/lib/counter/counter_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package counter import ( diff --git a/samples/krill/lib/dialer/dialer.go b/samples/device-simulator/lib/dialer/dialer.go similarity index 95% rename from samples/krill/lib/dialer/dialer.go rename to samples/device-simulator/lib/dialer/dialer.go index 21f5192..3267d0c 100644 --- a/samples/krill/lib/dialer/dialer.go +++ b/samples/device-simulator/lib/dialer/dialer.go @@ -1,4 +1,7 @@ -// Package dialers defines interfaces for GRPC and TCP dialers which are used across various parts of the simulation framework. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package dialers defines interfaces for GRPC and TCP dialers which are used across various parts of the simulation framework. // It also contains mock implementations for testing purposes and wrappers around the dial functions provided by the net and google grpc packages. package dialer diff --git a/samples/krill/lib/dialer/dialer_test.go b/samples/device-simulator/lib/dialer/dialer_test.go similarity index 96% rename from samples/krill/lib/dialer/dialer_test.go rename to samples/device-simulator/lib/dialer/dialer_test.go index 3cf9b17..8c69cd4 100644 --- a/samples/krill/lib/dialer/dialer_test.go +++ b/samples/device-simulator/lib/dialer/dialer_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package dialer import ( diff --git a/samples/krill/lib/environment/environment.go b/samples/device-simulator/lib/environment/environment.go similarity index 90% rename from samples/krill/lib/environment/environment.go rename to samples/device-simulator/lib/environment/environment.go index 6240a05..d909822 100644 --- a/samples/krill/lib/environment/environment.go +++ b/samples/device-simulator/lib/environment/environment.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package environment import "sync" diff --git a/samples/krill/lib/environment/environment_test.go b/samples/device-simulator/lib/environment/environment_test.go similarity index 87% rename from samples/krill/lib/environment/environment_test.go rename to samples/device-simulator/lib/environment/environment_test.go index ed88229..4e29e83 100644 --- a/samples/krill/lib/environment/environment_test.go +++ b/samples/device-simulator/lib/environment/environment_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package environment import ( diff --git a/samples/krill/lib/errors/errors.go b/samples/device-simulator/lib/errors/errors.go similarity index 88% rename from samples/krill/lib/errors/errors.go rename to samples/device-simulator/lib/errors/errors.go index 0b4e5cb..2a1ea2a 100644 --- a/samples/krill/lib/errors/errors.go +++ b/samples/device-simulator/lib/errors/errors.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package errors type Category int diff --git a/samples/krill/lib/errors/errors_test.go b/samples/device-simulator/lib/errors/errors_test.go similarity index 97% rename from samples/krill/lib/errors/errors_test.go rename to samples/device-simulator/lib/errors/errors_test.go index 81c5e03..12ec25a 100644 --- a/samples/krill/lib/errors/errors_test.go +++ b/samples/device-simulator/lib/errors/errors_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package errors import ( diff --git a/samples/krill/lib/errors/fiber.go b/samples/device-simulator/lib/errors/fiber.go similarity index 96% rename from samples/krill/lib/errors/fiber.go rename to samples/device-simulator/lib/errors/fiber.go index 06ff66d..d140aaa 100644 --- a/samples/krill/lib/errors/fiber.go +++ b/samples/device-simulator/lib/errors/fiber.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package errors import ( diff --git a/samples/krill/lib/exporter/exporter.go b/samples/device-simulator/lib/exporter/exporter.go similarity index 95% rename from samples/krill/lib/exporter/exporter.go rename to samples/device-simulator/lib/exporter/exporter.go index 1274047..4bdc1f4 100644 --- a/samples/krill/lib/exporter/exporter.go +++ b/samples/device-simulator/lib/exporter/exporter.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package exporter import ( @@ -11,7 +14,7 @@ import ( "sync" "time" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" ) type Exporter interface { diff --git a/samples/krill/lib/exporter/exporter_test.go b/samples/device-simulator/lib/exporter/exporter_test.go similarity index 97% rename from samples/krill/lib/exporter/exporter_test.go rename to samples/device-simulator/lib/exporter/exporter_test.go index d0a519e..6efd666 100644 --- a/samples/krill/lib/exporter/exporter_test.go +++ b/samples/device-simulator/lib/exporter/exporter_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package exporter import ( @@ -7,7 +10,7 @@ import ( "testing" "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" "github.com/stretchr/testify/require" ) diff --git a/samples/krill/lib/exporter/mock.go b/samples/device-simulator/lib/exporter/mock.go similarity index 87% rename from samples/krill/lib/exporter/mock.go rename to samples/device-simulator/lib/exporter/mock.go index b7923bd..c34f79c 100644 --- a/samples/krill/lib/exporter/mock.go +++ b/samples/device-simulator/lib/exporter/mock.go @@ -1,9 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package exporter import ( "io" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" ) type MockExporter struct { diff --git a/samples/krill/lib/exporter/provider.go b/samples/device-simulator/lib/exporter/provider.go similarity index 87% rename from samples/krill/lib/exporter/provider.go rename to samples/device-simulator/lib/exporter/provider.go index 362c4df..78bf87f 100644 --- a/samples/krill/lib/exporter/provider.go +++ b/samples/device-simulator/lib/exporter/provider.go @@ -1,8 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package exporter import ( "github.com/explore-iot-ops/lib/logger" - "github.com/explore-iot-ops/samples/krill/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" ) type CustomHistogramProvider struct { diff --git a/samples/krill/lib/exporter/stat.go b/samples/device-simulator/lib/exporter/stat.go similarity index 85% rename from samples/krill/lib/exporter/stat.go rename to samples/device-simulator/lib/exporter/stat.go index ca5ae2b..0ab0ed3 100644 --- a/samples/krill/lib/exporter/stat.go +++ b/samples/device-simulator/lib/exporter/stat.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package exporter import ( diff --git a/samples/krill/lib/expression/expression.go b/samples/device-simulator/lib/expression/expression.go similarity index 98% rename from samples/krill/lib/expression/expression.go rename to samples/device-simulator/lib/expression/expression.go index 2a94242..7b24eca 100644 --- a/samples/krill/lib/expression/expression.go +++ b/samples/device-simulator/lib/expression/expression.go @@ -1,4 +1,7 @@ -// Package expression provides functionality to evaluate simple mathematic expressions and functions. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package expression provides functionality to evaluate simple mathematic expressions and functions. package expression import ( diff --git a/samples/krill/lib/expression/expression_test.go b/samples/device-simulator/lib/expression/expression_test.go similarity index 98% rename from samples/krill/lib/expression/expression_test.go rename to samples/device-simulator/lib/expression/expression_test.go index 637e2b8..863d314 100644 --- a/samples/krill/lib/expression/expression_test.go +++ b/samples/device-simulator/lib/expression/expression_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package expression import ( diff --git a/samples/krill/lib/krill/configuration.go b/samples/device-simulator/lib/external/configuration.go similarity index 73% rename from samples/krill/lib/krill/configuration.go rename to samples/device-simulator/lib/external/configuration.go index 1a77867..4abf01b 100644 --- a/samples/krill/lib/krill/configuration.go +++ b/samples/device-simulator/lib/external/configuration.go @@ -1,4 +1,7 @@ -package krill +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package external type ( // Tag describes the structure of a simulated tag, including its ID, @@ -66,7 +69,7 @@ type ( RefData int `json:"refData" yaml:"refData"` } - // Configuration describes the overall configuration structure for the krill simulator. + // Configuration describes the overall configuration structure for the simulator. Configuration struct { Simulation Simulation `json:"simulation" yaml:"simulation"` Ports Ports `json:"ports" yaml:"ports"` @@ -87,7 +90,7 @@ const ( TagIDFormat = "%s__%s__%d" TagParentIDFormat = "%s__parent" TagChildIDFormat = "%s__child" - ProviderIDFormat = "krill_%s_asset_publish_counter" + ProviderIDFormat = "device_simulator_%s_asset_publish_counter" TagTimestampIDFormat = "%s__timestamp" OPCUATimeExpression = "now()" @@ -113,26 +116,10 @@ const ( ) const ( - Krill = ` -⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣤⣤⣀⠀⠀⠀⠀⠀⠀ -⠀⠀⢀⣀⡙⠻⢶⣶⣦⣴⣶⣶⣶⠾⠛⠛⠋⠉⠉⠉⠉⠙⠃⠀⠀⠀⠀⠀ -⠀⠀⠀⠉⠉⠙⠛⠛⠋⠉⠉⠡⣤⣴⣶⣶⣾⣿⣿⣿⣛⣩⣤⡤⠖⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⢠⣴⣾⠂⣴⣦⠈⣿⣿⣿⣿⣿⣿⠿⠛⣋⠁⠀⠀⠀⠀⠀ -⠀⠀⢀⣼⣿⣶⣄⡉⠻⣧⣌⣁⣴⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀⠀⠀ -⠀⠀⣾⣿⣿⣿⣿⣿⣦⡈⢻⣿⣿⣿⣿⡿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⡀⢻⣿⣿⣿⣿⣿⣿⣿⡄⠙⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⢠⣷⣄⡉⠻⢿⣿⣿⣿⠏⠠⢶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⢸⣿⣿⣿⣶⣤⣈⠙⠁⠰⣦⣀⠉⠻⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠘⢿⣿⣿⣿⣿⣿⡇⠠⣦⣄⠉⠳⣤⠈⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⢠⣌⣉⡉⠉⣉⡁⠀⠀⠙⠗⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠹⢿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -⠀⠀⠀⠀⠙⠻⣿⣿⠟⢀⣤⡀⠀⠀⠀⠀⠀⠀⣀⣀⣠⣤⣤⣤⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠿⠿⡿⠂⣀⣠⣤⣤⣤⣀⣉⣉⠉⠉⠀⠀⠀⠀ -⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠛⠛⠛⠛⠋⠉⠉⠁⠀⠀⠀⠀ - _ _ _ _ - | |__ _ _ <_>| || | - | / /| '_>| || || | - |_\_\|_| |_||_||_| - + Logo = ` + ____ _ _____ _ _ _ +| \ ___ _ _|_|___ ___ | __|_|_____ _ _| |___| |_ ___ ___ +| | | -_| | | | _| -_| |__ | | | | | | .'| _| . | _| +|____/|___|\_/|_|___|___| |_____|_|_|_|_|___|_|__,|_| |___|_| ` ) diff --git a/samples/krill/lib/krill/krill.go b/samples/device-simulator/lib/external/external.go similarity index 83% rename from samples/krill/lib/krill/krill.go rename to samples/device-simulator/lib/external/external.go index 9a1358c..9f05629 100644 --- a/samples/krill/lib/krill/krill.go +++ b/samples/device-simulator/lib/external/external.go @@ -1,31 +1,34 @@ -package krill +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package external import ( "errors" "fmt" "io" - "github.com/explore-iot-ops/samples/krill/components/broker" - "github.com/explore-iot-ops/samples/krill/components/client" - "github.com/explore-iot-ops/samples/krill/components/edge" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/limiter" - "github.com/explore-iot-ops/samples/krill/components/node" - "github.com/explore-iot-ops/samples/krill/components/observer" - "github.com/explore-iot-ops/samples/krill/components/outlet" - "github.com/explore-iot-ops/samples/krill/components/provider" - "github.com/explore-iot-ops/samples/krill/components/publisher" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/components/renderer" - "github.com/explore-iot-ops/samples/krill/components/site" - "github.com/explore-iot-ops/samples/krill/components/subscriber" - "github.com/explore-iot-ops/samples/krill/components/topic" - "github.com/explore-iot-ops/samples/krill/components/tracer" - "github.com/explore-iot-ops/samples/krill/lib/component" - "github.com/explore-iot-ops/samples/krill/lib/templater" + "github.com/explore-iot-ops/samples/device-simulator/components/broker" + "github.com/explore-iot-ops/samples/device-simulator/components/client" + "github.com/explore-iot-ops/samples/device-simulator/components/edge" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/limiter" + "github.com/explore-iot-ops/samples/device-simulator/components/node" + "github.com/explore-iot-ops/samples/device-simulator/components/observer" + "github.com/explore-iot-ops/samples/device-simulator/components/outlet" + "github.com/explore-iot-ops/samples/device-simulator/components/provider" + "github.com/explore-iot-ops/samples/device-simulator/components/publisher" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/components/renderer" + "github.com/explore-iot-ops/samples/device-simulator/components/site" + "github.com/explore-iot-ops/samples/device-simulator/components/subscriber" + "github.com/explore-iot-ops/samples/device-simulator/components/topic" + "github.com/explore-iot-ops/samples/device-simulator/components/tracer" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/lib/templater" ) -type KrillBuilder struct { +type DeviceSimulatorBuilder struct { brokerService component.Service[*broker.Component, component.ID] clientService component.Service[*client.Component, component.ID] edgeService component.Service[*edge.Component, component.ID] @@ -61,8 +64,8 @@ func New( subscriberService component.Service[*subscriber.Component, component.ID], topicService component.Service[*topic.Component, component.ID], tracerService component.Service[*tracer.Component, component.ID], -) *KrillBuilder { - return &KrillBuilder{ +) *DeviceSimulatorBuilder { + return &DeviceSimulatorBuilder{ brokerService: brokerService, clientService: clientService, edgeService: edgeService, @@ -82,7 +85,7 @@ func New( } } -func (builder *KrillBuilder) Parse(configuration Simulation) error { +func (builder *DeviceSimulatorBuilder) Parse(configuration Simulation) error { err := builder.brokerService.Create(BrokerID, &broker.Component{ Broker: configuration.Target.Host, Port: configuration.Target.Port, @@ -101,7 +104,7 @@ func (builder *KrillBuilder) Parse(configuration Simulation) error { return nil } -func (builder *KrillBuilder) ParseSite(configuration Site) error { +func (builder *DeviceSimulatorBuilder) ParseSite(configuration Site) error { err := builder.siteService.Create( component.ID(configuration.Name), &site.Component{ @@ -141,7 +144,7 @@ func (builder *KrillBuilder) ParseSite(configuration Site) error { return nil } -func (builder *KrillBuilder) ParseTopics( +func (builder *DeviceSimulatorBuilder) ParseTopics( configuration Site, tags []string, assets []string, @@ -192,7 +195,7 @@ func (builder *KrillBuilder) ParseTopics( return nil } -func (builder *KrillBuilder) ParseTopicAndPublisher( +func (builder *DeviceSimulatorBuilder) ParseTopicAndPublisher( configuration Site, id string, name string, @@ -227,7 +230,9 @@ func (builder *KrillBuilder) ParseTopicAndPublisher( ) } -func (builder *KrillBuilder) ParseTags(configuration Site) ([]string, error) { +func (builder *DeviceSimulatorBuilder) ParseTags( + configuration Site, +) ([]string, error) { switch configuration.PayloadFormat { case "JSONTagPerMessage": return builder.ParseJSONTagPerMessage(configuration) @@ -248,7 +253,9 @@ func (builder *KrillBuilder) ParseTags(configuration Site) ([]string, error) { } } -func (builder *KrillBuilder) 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) @@ -261,7 +268,7 @@ func (builder *KrillBuilder) ParseAssets(configuration Site) ([]string, error) { return assets, nil } -func (builder *KrillBuilder) ParseAsset( +func (builder *DeviceSimulatorBuilder) ParseAsset( configuration Site, count int, ) (string, error) { @@ -304,7 +311,7 @@ func (builder *KrillBuilder) ParseAsset( return clientID, nil } -func (builder *KrillBuilder) ParseJSONTagPerMessage( +func (builder *DeviceSimulatorBuilder) ParseJSONTagPerMessage( configuration Site, ) ([]string, error) { err := builder.formatterService.Create( @@ -331,7 +338,7 @@ func (builder *KrillBuilder) ParseJSONTagPerMessage( return tagNames, nil } -func (builder *KrillBuilder) ParseJSONTag( +func (builder *DeviceSimulatorBuilder) ParseJSONTag( siteName string, tag Tag, count int, @@ -359,7 +366,9 @@ func (builder *KrillBuilder) ParseJSONTag( return tagID, nil } -func (builder *KrillBuilder) ParseOPCUA(configuration Site) ([]string, error) { +func (builder *DeviceSimulatorBuilder) ParseOPCUA( + configuration Site, +) ([]string, error) { err := builder.ParseFormatter( configuration.Name, formatter.JSON, @@ -435,7 +444,7 @@ func (builder *KrillBuilder) ParseOPCUA(configuration Site) ([]string, error) { return []string{configuration.Name}, nil } -func (builder *KrillBuilder) ParseOPCUATag( +func (builder *DeviceSimulatorBuilder) ParseOPCUATag( configuration Site, rootId string, tag Tag, @@ -474,7 +483,7 @@ func (builder *KrillBuilder) ParseOPCUATag( ) } -func (builder *KrillBuilder) ParseExpressionNode( +func (builder *DeviceSimulatorBuilder) ParseExpressionNode( rootNodeId, nodeId, edgeId, nodeExpression string, edgeConfiguration any, edgeType edge.Type, @@ -495,7 +504,7 @@ func (builder *KrillBuilder) ParseExpressionNode( }) } -func (builder *KrillBuilder) ParseCollectionNode( +func (builder *DeviceSimulatorBuilder) ParseCollectionNode( rootNodeId, nodeId, edgeId, edgeConfiguration string, ) error { err := builder.nodeService.Create(component.ID(nodeId), &node.Component{ @@ -513,7 +522,7 @@ func (builder *KrillBuilder) ParseCollectionNode( }) } -func (builder *KrillBuilder) ParseComplex( +func (builder *DeviceSimulatorBuilder) ParseComplex( configuration Site, format formatter.Type, ) ([]string, error) { @@ -543,7 +552,7 @@ func (builder *KrillBuilder) ParseComplex( return []string{configuration.Name}, nil } -func (builder *KrillBuilder) ParseFormatter( +func (builder *DeviceSimulatorBuilder) ParseFormatter( id string, format formatter.Type, nodeType node.Type, @@ -561,7 +570,7 @@ func (builder *KrillBuilder) ParseFormatter( return builder.ParseRootNode(id, id, nodeType) } -func (builder *KrillBuilder) ParseRootNode( +func (builder *DeviceSimulatorBuilder) ParseRootNode( formatterID string, id string, nodeType node.Type, @@ -579,7 +588,7 @@ func (builder *KrillBuilder) ParseRootNode( }) } -func (builder *KrillBuilder) ParseFlat( +func (builder *DeviceSimulatorBuilder) ParseFlat( configuration Site, format formatter.Type, ) ([]string, error) { diff --git a/samples/krill/lib/krill/krill_test.go b/samples/device-simulator/lib/external/external_test.go similarity index 90% rename from samples/krill/lib/krill/krill_test.go rename to samples/device-simulator/lib/external/external_test.go index 2c28c9d..21b2b24 100644 --- a/samples/krill/lib/krill/krill_test.go +++ b/samples/device-simulator/lib/external/external_test.go @@ -1,49 +1,52 @@ -package krill +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package external import ( "testing" - "github.com/explore-iot-ops/samples/krill/components/edge" - "github.com/explore-iot-ops/samples/krill/components/formatter" - "github.com/explore-iot-ops/samples/krill/components/node" - "github.com/explore-iot-ops/samples/krill/components/renderer" - "github.com/explore-iot-ops/samples/krill/lib/component" + "github.com/explore-iot-ops/samples/device-simulator/components/edge" + "github.com/explore-iot-ops/samples/device-simulator/components/formatter" + "github.com/explore-iot-ops/samples/device-simulator/components/node" + "github.com/explore-iot-ops/samples/device-simulator/components/renderer" + "github.com/explore-iot-ops/samples/device-simulator/lib/component" "github.com/stretchr/testify/require" ) var ( - MockKrillTag = Tag{ + MockDeviceSimulatorTag = Tag{ ID: "float_1", Configuration: "1", Count: 1, MissingChance: 0, } - MockKrillRate = Rate{ + MockDeviceSimulatorRate = Rate{ MessagesPerPeriod: 10, PeriodSeconds: 1, TagsPerMessage: 1, } - MockKrillTarget = Target{ + MockDeviceSimulatorTarget = Target{ Host: "localhost", Port: 1883, } - MockKrillSite = Site{ + MockDeviceSimulatorSite = Site{ Name: "site0", Tags: []Tag{ - MockKrillTag, + MockDeviceSimulatorTag, }, AssetCount: 1, - Rate: MockKrillRate, + Rate: MockDeviceSimulatorRate, PayloadFormat: "JSON", TopicFormat: "{{.SiteName}}/{{.AssetName}}", QoSLevel: 1, MQTTVersion: "v5", } - MockKrillConfiguration = Simulation{ + MockDeviceSimulatorConfiguration = Simulation{ Sites: []Site{ - MockKrillSite, + MockDeviceSimulatorSite, }, - Target: MockKrillTarget, + Target: MockDeviceSimulatorTarget, } ) @@ -66,7 +69,7 @@ func TestMain(m *testing.M) { } func TestParseExpressionNode(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { require.Equal(t, MockChildNodeID, string(identifier)) @@ -98,7 +101,7 @@ func TestParseExpressionNode(t *testing.T) { } func TestParseExpressionNodeNodeError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { return &component.MockError{} @@ -111,7 +114,7 @@ func TestParseExpressionNodeNodeError(t *testing.T) { } func TestParseCollectionNode(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { require.Equal(t, MockChildNodeID, string(identifier)) @@ -141,7 +144,7 @@ func TestParseCollectionNode(t *testing.T) { } func TestParseCollectionNodeNodeError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { return &component.MockError{} @@ -154,7 +157,7 @@ func TestParseCollectionNodeNodeError(t *testing.T) { } func TestParseRootNode(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { require.Equal(t, MockRootNodeID, string(identifier)) @@ -181,7 +184,7 @@ func TestParseRootNode(t *testing.T) { } func TestParseRootNodeNodeError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { return &component.MockError{} @@ -194,7 +197,7 @@ func TestParseRootNodeNodeError(t *testing.T) { } func TestParseFormatter(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { require.Equal(t, MockFormatterID, string(identifier)) @@ -218,7 +221,7 @@ func TestParseFormatter(t *testing.T) { } func TestParseFormatterError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { return &component.MockError{} @@ -240,7 +243,7 @@ func TestParseFormatterError(t *testing.T) { } func TestParseFlat(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { require.Equal(t, MockFormatterType, entity.Type) @@ -278,7 +281,7 @@ func TestParseFlat(t *testing.T) { } func TestParseFlatFormatterError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { return &component.MockError{} @@ -291,7 +294,7 @@ func TestParseFlatFormatterError(t *testing.T) { } func TestParseFlatExpressionNodeError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { return nil @@ -324,7 +327,7 @@ func TestParseFlatExpressionNodeError(t *testing.T) { } func TestParseJSONTag(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { return nil @@ -354,7 +357,7 @@ func TestParseJSONTag(t *testing.T) { } func TestParseJSONTagRootNodeError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { return &component.MockError{} @@ -371,7 +374,7 @@ func TestParseJSONTagRootNodeError(t *testing.T) { } func TestParseJSONTagExpressionNodeError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ nodeService: &component.MockService[*node.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *node.Component) error { return nil @@ -392,7 +395,7 @@ func TestParseJSONTagExpressionNodeError(t *testing.T) { } func TestParseJSONTagPerMessage(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { require.Equal(t, MockSiteName, string(identifier)) @@ -429,7 +432,7 @@ func TestParseJSONTagPerMessage(t *testing.T) { } func TestParseJSONTagPerMessageFormatterError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { return &component.MockError{} @@ -442,7 +445,7 @@ func TestParseJSONTagPerMessageFormatterError(t *testing.T) { } func TestParseJSONTagPerMessageParseJSONTagError(t *testing.T) { - builder := &KrillBuilder{ + builder := &DeviceSimulatorBuilder{ formatterService: &component.MockService[*formatter.Component, component.ID]{ OnCreate: func(identifier component.ID, entity *formatter.Component) error { return nil diff --git a/samples/krill/lib/flatten/flatten.go b/samples/device-simulator/lib/flatten/flatten.go similarity index 96% rename from samples/krill/lib/flatten/flatten.go rename to samples/device-simulator/lib/flatten/flatten.go index 7c4efdd..170d52e 100644 --- a/samples/krill/lib/flatten/flatten.go +++ b/samples/device-simulator/lib/flatten/flatten.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package flatten import ( diff --git a/samples/krill/lib/flatten/flatten_test.go b/samples/device-simulator/lib/flatten/flatten_test.go similarity index 96% rename from samples/krill/lib/flatten/flatten_test.go rename to samples/device-simulator/lib/flatten/flatten_test.go index 3a9c967..726045e 100644 --- a/samples/krill/lib/flatten/flatten_test.go +++ b/samples/device-simulator/lib/flatten/flatten_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package flatten import ( diff --git a/samples/krill/lib/gauge/gauge.go b/samples/device-simulator/lib/gauge/gauge.go similarity index 91% rename from samples/krill/lib/gauge/gauge.go rename to samples/device-simulator/lib/gauge/gauge.go index 0b20825..dd435ea 100644 --- a/samples/krill/lib/gauge/gauge.go +++ b/samples/device-simulator/lib/gauge/gauge.go @@ -1,10 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package gauge import ( "fmt" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" "github.com/prometheus/client_golang/prometheus" ) diff --git a/samples/krill/lib/gauge/gauge_test.go b/samples/device-simulator/lib/gauge/gauge_test.go similarity index 96% rename from samples/krill/lib/gauge/gauge_test.go rename to samples/device-simulator/lib/gauge/gauge_test.go index 2ff2dd1..4195032 100644 --- a/samples/krill/lib/gauge/gauge_test.go +++ b/samples/device-simulator/lib/gauge/gauge_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package gauge import ( diff --git a/samples/krill/lib/histogram/histogram.go b/samples/device-simulator/lib/histogram/histogram.go similarity index 94% rename from samples/krill/lib/histogram/histogram.go rename to samples/device-simulator/lib/histogram/histogram.go index 1538519..9cbb01c 100644 --- a/samples/krill/lib/histogram/histogram.go +++ b/samples/device-simulator/lib/histogram/histogram.go @@ -1,12 +1,15 @@ -// Package histogram provides the histogram type implementation of the Provider interface. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package histogram provides the histogram type implementation of the Provider interface. // Histogram Providers represent the histogramVec prometheus metrics. package histogram import ( "fmt" - "github.com/explore-iot-ops/samples/krill/components/registry" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/components/registry" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" "github.com/prometheus/client_golang/prometheus" ) diff --git a/samples/krill/lib/histogram/histogram_test.go b/samples/device-simulator/lib/histogram/histogram_test.go similarity index 96% rename from samples/krill/lib/histogram/histogram_test.go rename to samples/device-simulator/lib/histogram/histogram_test.go index 13ca48e..646ee9b 100644 --- a/samples/krill/lib/histogram/histogram_test.go +++ b/samples/device-simulator/lib/histogram/histogram_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package histogram import ( diff --git a/samples/krill/lib/templater/templater.go b/samples/device-simulator/lib/templater/templater.go similarity index 93% rename from samples/krill/lib/templater/templater.go rename to samples/device-simulator/lib/templater/templater.go index 923f400..c126c20 100755 --- a/samples/krill/lib/templater/templater.go +++ b/samples/device-simulator/lib/templater/templater.go @@ -1,4 +1,7 @@ -// Package templater contains the templating functionality used to convert a general request body template into a body specific to a particular request. +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +// package templater contains the templating functionality used to convert a general request body template into a body specific to a particular request. package templater import ( diff --git a/samples/krill/lib/templater/templater_test.go b/samples/device-simulator/lib/templater/templater_test.go similarity index 93% rename from samples/krill/lib/templater/templater_test.go rename to samples/device-simulator/lib/templater/templater_test.go index 57dd893..8cd6547 100755 --- a/samples/krill/lib/templater/templater_test.go +++ b/samples/device-simulator/lib/templater/templater_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package templater import ( @@ -5,7 +8,7 @@ import ( "testing" "text/template" - "github.com/explore-iot-ops/samples/krill/lib/errors" + "github.com/explore-iot-ops/samples/device-simulator/lib/errors" "github.com/stretchr/testify/require" ) diff --git a/samples/callout/magefile.go b/samples/device-simulator/magefile.go similarity index 56% rename from samples/callout/magefile.go rename to samples/device-simulator/magefile.go index da28a84..cd248db 100644 --- a/samples/callout/magefile.go +++ b/samples/device-simulator/magefile.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + //go:build mage package main @@ -9,10 +12,10 @@ import ( func CI() error { return mage.CI( - "github.com/explore-iot-ops/samples/callout/", + "github.com/explore-iot-ops/samples/device-simulator/", map[string]any{"cmd": nil}, 3000, 0.00, - 0, + 82.50, ) } 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/callout/Dockerfile b/samples/http-grpc-callout/Dockerfile similarity index 59% rename from samples/callout/Dockerfile rename to samples/http-grpc-callout/Dockerfile index 62bd499..1a70d7c 100644 --- a/samples/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/README.md b/samples/http-grpc-callout/README.md new file mode 100644 index 0000000..c787ba6 --- /dev/null +++ b/samples/http-grpc-callout/README.md @@ -0,0 +1,68 @@ +# 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. + +## Usage + +### Server as a Pod + +```sh +# From the root of the http-grpc-callout directory. +docker build ../.. -f Dockerfile -t .azurecr.io/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 .azurecr.io/http-grpc-callout:latest + +# Push or load your newly built image into your cluster, depending on the k8s setup. +# docker push .azurecr.io/http-grpc-callout:latest # Using AKS + Connected ACR +# minikube load .azurecr.io/http-grpc-callout:latest # Using minikube +# docker save .azurecr.io/http-grpc-callout:latest | k3s ctr images import - # Using K3s + +kubectl run http-grpc-callout --image=.azurecr.io/http-grpc-callout:latest --stdin < config.yml +``` + +```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/callout/cmd/config.go b/samples/http-grpc-callout/cmd/config.go similarity index 93% rename from samples/callout/cmd/config.go rename to samples/http-grpc-callout/cmd/config.go index cff7a66..146eca5 100644 --- a/samples/callout/cmd/config.go +++ b/samples/http-grpc-callout/cmd/config.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package main type Configuration struct { diff --git a/samples/callout/cmd/config.yml b/samples/http-grpc-callout/cmd/config.yml similarity index 83% rename from samples/callout/cmd/config.yml rename to samples/http-grpc-callout/cmd/config.yml index 0154e30..4277871 100644 --- a/samples/callout/cmd/config.yml +++ b/samples/http-grpc-callout/cmd/config.yml @@ -4,15 +4,15 @@ servers: http: port: 3333 resources: - - path: /example1 # PUT localhost:3333/example -Body { "field": 123 } - method: POST + - path: /example + method: GET status: 200 outputs: ["output1", "output2"] response: | { "hello": "world" } - - path: /example # POST localhost:3333/example + - path: /example method: POST status: 200 outputs: ["output3", "output4"] diff --git a/samples/callout/cmd/grpc.go b/samples/http-grpc-callout/cmd/grpc.go similarity index 92% rename from samples/callout/cmd/grpc.go rename to samples/http-grpc-callout/cmd/grpc.go index e689d69..1917c40 100644 --- a/samples/callout/cmd/grpc.go +++ b/samples/http-grpc-callout/cmd/grpc.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package main import ( diff --git a/samples/callout/cmd/main.go b/samples/http-grpc-callout/cmd/main.go similarity index 89% rename from samples/callout/cmd/main.go rename to samples/http-grpc-callout/cmd/main.go index e0aa34d..d58d803 100644 --- a/samples/callout/cmd/main.go +++ b/samples/http-grpc-callout/cmd/main.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package main import ( @@ -100,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/callout/cmd/output.go b/samples/http-grpc-callout/cmd/output.go similarity index 97% rename from samples/callout/cmd/output.go rename to samples/http-grpc-callout/cmd/output.go index d4bebbc..a8da8a8 100644 --- a/samples/callout/cmd/output.go +++ b/samples/http-grpc-callout/cmd/output.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package main import ( diff --git a/samples/callout/cmd/server.go b/samples/http-grpc-callout/cmd/server.go similarity index 97% rename from samples/callout/cmd/server.go rename to samples/http-grpc-callout/cmd/server.go index e95c457..ee3fdf3 100644 --- a/samples/callout/cmd/server.go +++ b/samples/http-grpc-callout/cmd/server.go @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + package main import ( diff --git a/samples/callout/go.mod b/samples/http-grpc-callout/go.mod similarity index 96% rename from samples/callout/go.mod rename to samples/http-grpc-callout/go.mod index 62127ef..b1dad87 100644 --- a/samples/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/callout/go.sum b/samples/http-grpc-callout/go.sum similarity index 100% rename from samples/callout/go.sum rename to samples/http-grpc-callout/go.sum diff --git a/samples/http-grpc-callout/magefile.go b/samples/http-grpc-callout/magefile.go new file mode 100644 index 0000000..0fe4bc2 --- /dev/null +++ b/samples/http-grpc-callout/magefile.go @@ -0,0 +1,23 @@ +// 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/krill/.gitignore b/samples/krill/.gitignore deleted file mode 100644 index 5e86a38..0000000 --- a/samples/krill/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -bin -.vscode/* -/mako -dns.yaml -/src/**/config.json -/bin -/krill -/listen -/mqtt -/manager -/simulator -dist/ -cover.tmp.out -coverage.out -web -cover.* \ No newline at end of file diff --git a/samples/krill/magefile.go b/samples/krill/magefile.go deleted file mode 100644 index 21d98fc..0000000 --- a/samples/krill/magefile.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build mage - -package main - -import ( - //mage:import - "github.com/explore-iot-ops/lib/mage" -) - -func CI() error { - return mage.CI( - "github.com/explore-iot-ops/samples/krill/", - map[string]any{"cmd/krill": nil}, - 3000, - 0.00, - 82.50, - ) -}