Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to variable sequences and file based configuration #32

Merged
merged 7 commits into from
Sep 29, 2021

Conversation

fbeltrao
Copy link
Collaborator

Purpose

  • Allow defining a variable that is created out of a sequence of values
  • Allow defining the configuration in file

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

TechPreacher
TechPreacher previously approved these changes Sep 15, 2021
Copy link
Collaborator

@TechPreacher TechPreacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!!!

README.md Outdated Show resolved Hide resolved
gukoff
gukoff previously approved these changes Sep 21, 2021
Copy link
Collaborator

@gukoff gukoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved 🐛

side note

We could further support variables referencing to each other, with only one rule: variable is allowed to reference any variable declared before it.

All it takes is to replace strings by TelemetryTemplates in variable values on startup. And when generating values, evaluate these templates to strings.

Whether these super capabilities would help any of our users, I don't know 🙃

But one could do wild things like:

[
    {
      "name": "Counter"
    },
    {
      "name": "DeviceName",
      "random": true,
      "values": [ "Alice", "Bob" ]
    },
    {
      "name": "DeviceLength",
      "sequence": true,
      "values": [ "$.Counter", "$.Counter", "$.Counter", "$.Counter", "$.Counter", "true", "false", "$.Counter" ]
    },
    {
      "name": "DeviceLengthWithCmSuffix",
      "value": "$DeviceLength cm"
    },
    {
      "name": "DeviceDescription",
      "random": true,
      "value": ["$DeviceName of length $DeviceLengthWithCmSuffix", "$DeviceName:$DeviceLength"]
    }
  ]

src/IotTelemetrySimulator/PayloadGenerator.cs Outdated Show resolved Hide resolved
src/IotTelemetrySimulator/PayloadGenerator.cs Outdated Show resolved Hide resolved
src/IotTelemetrySimulator/Program.cs Outdated Show resolved Hide resolved
src/IotTelemetrySimulator/RunnerConfiguration.cs Outdated Show resolved Hide resolved
src/IotTelemetrySimulator/RunnerConfiguration.cs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/IotTelemetrySimulator/TelemetryValues.cs Show resolved Hide resolved
src/IotTelemetrySimulator/TelemetryValues.cs Outdated Show resolved Hide resolved
src/IotTelemetrySimulator/TelemetryValues.cs Outdated Show resolved Hide resolved
gukoff
gukoff previously approved these changes Sep 27, 2021
src/IotTelemetrySimulator/TelemetryValues.cs Outdated Show resolved Hide resolved
src/IotTelemetrySimulator/TelemetryValues.cs Show resolved Hide resolved
src/IotTelemetrySimulator/TelemetryValues.cs Show resolved Hide resolved
Add additional tests
Copy link
Collaborator

@gukoff gukoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve, but in the future I'd limit ResetNotUsedReferencedVariables to a particular variable type that needs it:
#36 (comment)

Copy link
Collaborator

@TechPreacher TechPreacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good to me :)

@fbeltrao fbeltrao merged commit 65c0de7 into Azure-Samples:master Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants