Skip to content

[RFC] River: A Flow-optimized config language #1839

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

Merged
merged 9 commits into from
Aug 24, 2022
Merged

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Jun 29, 2022

This RFC expands on the expressions design proposed by #1546 with a suggestion that a custom config language for Flow expressions is required to make Flow be as useful and powerful as possible. The current implementation of Flow uses HCL, but with the number of changes I had to make to HCL to get things to work, it doesn't appear to be the best fit.

I would prefer not creating a new language, but I see it as our only option for Flow. Most of this RFC focuses on the rationale for how I reached this conclusion, why existing languages aren't the best fit, and why it's important to do this for Flow earlier instead of later.

Additionally, in light of proposing a new language, I focus on reducing the learning curve as much as possible to reduce friction from users migrating from the existing YAML configs to Flow.

The current prototype of River is in the main branch, but is subject to removal if we abandon the proposal.

@rfratto rfratto requested a review from mattdurham June 29, 2022 18:07
@rfratto rfratto changed the title [RFC] River: Flow-specific configuration language [RFC] River: A Flow-optimized config language Jun 29, 2022

### Why now?

Grafana Agent Flow is already a dramatic change to the Agent. To avoid users
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this new language necessary for an MVP? I was thinking if HCL is enough for the scope of the MVP, should we invest time on design a new language if later users wouldn't be happy to adopt Flow?

* Make it easy for developers to create Flow components which operate with
arbitrary Go values (interfaces, channels, etc.)
* Expose error messages in an easily understandable and actionable way
* Natively support using Go values of any type in config expressions
Copy link
Member

Choose a reason for hiding this comment

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

It's the fourth time we're referencing 'arbitrary Go values' in the summary so we definitely consider it important to us. We mention 'constructing data pipelines', but do we have any more concrete explanation to make apparent why someone would need to pass a channel, an interface or a complex Go struct around?

Copy link
Member Author

@rfratto rfratto Jul 19, 2022

Choose a reason for hiding this comment

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

I feel like I'm already covering this when I first brought up the term:

Values can refer to arbitrary Go values like interfaces or channels, enabling component developers to easily allow users to construct data pipelines using Go APIs without requiring knowledge of the underlying implementation.

Is there a way I could make this clearer?

rfratto added a commit to rfratto/agent that referenced this pull request Jul 5, 2022
This commit introduces the lexer for River (grafana#1839). It is
not wired in anywhere, and is the first of several PRs to slowly bring
over functionality from the prototype.

Note that this commit does not indicate we will ship River, just that we
are continuing the prototyping process in the main branch. pkg/river may
still be removed in the future in favor of an alternative solution.
rfratto added a commit to rfratto/agent that referenced this pull request Jul 5, 2022
This commit introduces the lexer for River (grafana#1839). It is
not wired in anywhere, and is the first of several PRs to slowly bring
over functionality from the prototype. Most of the scanner code has been
copied from go/scanner, adapted slightly for River and decorated with
extra comments.

Note that this commit does not indicate we will ship River, just that we
are continuing the prototyping process in the main branch. pkg/river may
still be removed in the future in favor of an alternative solution.
rfratto added a commit that referenced this pull request Jul 6, 2022
* pkg/river: introduce scanner package

This commit introduces the lexer for River (#1839). It is
not wired in anywhere, and is the first of several PRs to slowly bring
over functionality from the prototype. Most of the scanner code has been
copied from go/scanner, adapted slightly for River and decorated with
extra comments.

Note that this commit does not indicate we will ship River, just that we
are continuing the prototyping process in the main branch. pkg/river may
still be removed in the future in favor of an alternative solution.

* pkg/river: fix lint errors

* pkg/river: hush unparam warnings for Scanner.switch2

Assuming `=` as the next rune seems harder to follow than explicitly
passing it, even if it's always the same argument.

* address review feedback

* river/scanner: fix grammar for float

Float should allow exponents on numbers without a `.`

* river/scanner: denote that sign after exponent is optional
rfratto added a commit to rfratto/agent that referenced this pull request Jul 6, 2022
This commit introduces the parser for River (grafana#1839). It is
not wired in anywhere, and is the second of several PRs to slowly bring
over functionality from the prototype. The parser code has been highly
inspired by go/parser, with tests copied from the go/parser tests.

Note that this commit does not indicate we will ship river, just that we
are continuing the prototyping process in the main branch. pkg/river may
still be removed in the future in favor of an alternative solution for
Flow.
rfratto added a commit that referenced this pull request Jul 7, 2022
* pkg/river: introduce parser package

This commit introduces the parser for River (#1839). It is
not wired in anywhere, and is the second of several PRs to slowly bring
over functionality from the prototype. The parser code has been highly
inspired by go/parser, with tests copied from the go/parser tests.

Note that this commit does not indicate we will ship river, just that we
are continuing the prototyping process in the main branch. pkg/river may
still be removed in the future in favor of an alternative solution for
Flow.

* update golangci-lint

* river: fix bugs found by parser fuzzer

* update Go and golanglint-ci versions in Drone for Windows

* update SHA for golangci-lint

* windows ci: only update Go since the Windows job doesn't do any linting

* .gitattributes: disable autocrlf and force \n line endings for fuzz tests

* wip: experiment with using a golang windows container for windows tests

* Revert "wip: experiment with using a golang windows container for windows tests"

This reverts commit a32b59d.

* river/parser: include comments when parsing

* river/parser: add missing ) in error message
rfratto added a commit to rfratto/agent that referenced this pull request Jul 7, 2022
This commit introduces the first pass at a value package for River
(grafana#1839). It is not wired in anywhere yet, and further PRs
will improve the package and eventually wire it in.

Note that this commit does not indicate we will ship River, just that we
are continuing the prototyping process in the main branch. pkg/river may
still be removed in the future in favor of an alternative solution for
Flow.

This commit purposefully leaves three larger tasks incomplete to be done
in follow up commits:

1. Ability to invoke function values
2. Proper encoding/decoding to Go structs with rvr block tags (currently,
   labels are ignored)
3. Decoding to Go structs with missing required attributes should fail
@marctc
Copy link
Contributor

marctc commented Aug 9, 2022

@rfratto we probably should merge this before releasing any flow version, wdyt?

@rfratto
Copy link
Member Author

rfratto commented Aug 9, 2022

@rfratto we probably should merge this before releasing any flow version, wdyt?

Yeah, agreed, I'll open it up for final review now.

@rfratto rfratto marked this pull request as ready for review August 9, 2022 20:18
Copy link
Collaborator

@mattdurham mattdurham left a comment

Choose a reason for hiding this comment

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

Ship it

@rfratto rfratto enabled auto-merge (squash) August 24, 2022 19:06
@rfratto rfratto merged commit 97a55d0 into grafana:main Aug 24, 2022
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Mar 20, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants