Skip to content

Conversation

svix-onelson
Copy link
Contributor

@svix-onelson svix-onelson commented May 15, 2023

Alright y'all. After a bunch of conversations about the overall config and mental model to apply to the project (from the user perspective), this PR ended up huge. It'll be a tough review. I'm sorry 😭

This is a pretty large shift.

Here's a breakdown of the broad strokes:

  • The Plugin trait was removed from -types.
  • New traits added: SenderInput and ReceiverOutput to represent the
    non-svix portions of the dataflow.
  • Removed the -plugin-webhook-receiver plugin crate.
    • moved the http server from the -plugin-webhook-receiver crate into svix-bridge.
    • "queue forwarders" into the -plugin-queue-consumer crate.
  • Renamed the -plugin-queue-consumer crate to just -plugin-queue (it
    now provides both SenderInput and ReceiverOutput implementation for the various queue backends.
  • all crates etc have been renamed: s/svix-webhook-bridge/svix-bridge/

What else, what else, what else...

The example config has been split into 2: one showing senders and another for receivers.
The readme has been gutted (but probably needs to be fleshed out a bit more... again). It felt silly to effectively duplicate the example configs in code fence blocks a 2nd time.

To sweeten the deal, new test coverage has been added for select portions of the config parsing as well as for the HTTP receiver stuff.

Both the sender and receiver example configs are now checked in the test suite to make sure they at least parse without failure. These tests should be expanded to inspect the actual data, but this diff is so big... 😭

We didn't have any tests for the HTTP handler execution before this, so that's very nice to have.

@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch from ccd3933 to 34dd014 Compare May 15, 2023 17:24
@svix-james
Copy link
Contributor

LGTM

@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch from 34dd014 to 4db3f28 Compare May 16, 2023 17:54
@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch from 96ab119 to 5dc92fe Compare May 16, 2023 23:51
@svix-onelson svix-onelson marked this pull request as ready for review May 17, 2023 00:30
@svix-onelson svix-onelson changed the title WIP: polish bridge config polish bridge config May 17, 2023
@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch 2 times, most recently from 6181249 to a16bc3d Compare May 17, 2023 00:32
@tasn
Copy link
Member

tasn commented May 17, 2023

@svix-onelson, can you do a "diff" (maybe in a new PR) that's just the result files? As in, just have diffs where new files are added so that we can comment on the syntax easily (like a PR review) with the annoying diff lines. Does this make sense?

@svix-onelson
Copy link
Contributor Author

@svix-onelson, can you do a "diff" (maybe in a new PR) that's just the result files? As in, just have diffs where new files are added so that we can comment on the syntax easily (like a PR review) with the annoying diff lines. Does this make sense?

Yeah, I think that's what I did to kick off the conversation. I'll copy the example file to a new file.

@svix-onelson
Copy link
Contributor Author

@tasn 5937888 adds a full copy of the example config (svix-webhook-bridge.example2.yaml). Drop your notes on that one and I can try to incorporate the updates to make it that real.

@svix-onelson
Copy link
Contributor Author

Discussed with @tasn - there are a couple of action items to clear before this moves forward.
The plan is to first do some exploratory "what if" example configs to examine:

  • what if the jargon was more specific, less generic?
    • Ex: splitting the config into "producers" and consumers instead of just "plugins."
  • what if we rebrand in terms of [webhook] "senders" and "receivers" instead of queue-consumer vs webhook-receiver
  • what if the HTTP interface was a shared resource (like the JS runtime), "owned by bridge" and plugins optionally register routes mapping back to functions?
  • (building on prev) what if (input, transformation, output) was the shape of all config items?
    • make it so HTTP or webhook is an input and the outputs are the various queue backends.

So, I guess the idea will be to sketch out these alternate realities and see which feels the most accessible, then after, look at the code changes needed to make them real.

I'll post a series of new yaml files to explore these ideas as subsequent revs, then we'll discuss.

@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch from 7a65e18 to 935101d Compare May 19, 2023 01:48
@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch from c43d498 to 5bba7f0 Compare May 19, 2023 16:49
Comment on lines 18 to 22
input:
type: "rabbitmq"
queue: "local"
uri: "amqp://example.com/%2f"
# Optional transformation. JSON bodies will be forwarded as-is when unset.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Omitted the requeue_on_nack -- let's assume we can pick a default either way and document what it is, though this feels like a "stopped clock is correct twice a day" situation to me.

Comment on lines 19 to 21
# The "webhook" input type uses the HTTP listener. POST bodies/headers are "handled" by forwarding to the
# configured "output."
type: "webhook"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer "webhook" to "http" since we're biased towards POST requests with JSON objects for bodies. I'd expect an "HTTP" input to have a lot more config options to let me go wild, but "webhook" sort of curbs that feeling for me.

@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch from 13dec2d to 2c744af Compare May 19, 2023 17:59
@svix-onelson
Copy link
Contributor Author

So, I'm going to dig in on the supporting refactors to make .example5.{sender,receiver}.yaml a reality and assume that the larger effort changes required will apply for wherever we finally land.

The biggest change required seems to be

  • moving the HTTP server code into the bridge binary
  • (probably) splitting Plugin trait into 2 separate types to represent sending vs receiving.

There might be some other things in the HTTP code that needs to change but I'm not sure what that might include right now.

The rewrangling of configs to match the examples is probably the smallest lift overall.


If there are extra changes in direction for the config part, I'm betting the refactoring of the HTTP stuff will still make sense. It feels right that the binary owns the HTTP server just like it owns the JS Runtime.

The doubt I have is that we might want to listen on other protocols in the future, and making the listener "belong to the plugin" would make the most sense for that, but as they say: "you ain't gonna need it" (YAGNI). That's tomorrow's problem.

@@ -0,0 +1,65 @@
log_level: "debug"
Copy link
Member

Choose a reason for hiding this comment

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

Everything looks excellent in this and the senders examples!

One thing I'd make sure that we support in this YAML is loading from env var. Does YAML by any chance have an extension that supports just loading from env vars so I can do? key: $MY_KEY in the config and then we'll load the key from env var or env var file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing is provided for this in serde_yaml from what I saw. We could pre-process the config to expand vars before parsing the YAML using something like shellexpand.

In the past I'd used envsubst, in a shell command but that's a bit clumsy for launching services. My use case was for deployments, etc where you're usually running a series of commands anyway.

Copy link
Member

Choose a reason for hiding this comment

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

No worries, this can be second step. I think shellexpand sounds scary/too much.
Anyhow, if there's something that can do it well we can consider it, but as long as it's very limited with what it does.

@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch 7 times, most recently from 6a05701 to a286318 Compare May 24, 2023 03:57
This is a pretty large shift.

Here's a breakdown of the broad strokes:
- The `Plugin` trait was removed from -types.
- New traits added: `SenderInput` and `ReceiverOutput` to represent the
  non-svix portions of the dataflow.
- Removed the -webhook-receiver plugin crate.
  - moved the http server from the `-plugin-webhook-receiver` crate into bridge.
  - "queue forwarders" into the -plugin-queue-consumer crate.
- Renamed the -plugin-queue-consumer crate to just `-plugin-queue` (it
  now provides both `SenderInput` and `ReceiverOutput` implementations).
- Configuration revamp to align with the sender/receiver split.
@svix-onelson svix-onelson force-pushed the onelson/bridge-config-redux branch from 1d1f31e to 4b222c1 Compare May 24, 2023 16:43
@svix-onelson svix-onelson merged commit fdc5b1a into onelson/bridge May 24, 2023
@svix-onelson svix-onelson deleted the onelson/bridge-config-redux branch May 24, 2023 16:59
svix-onelson added a commit that referenced this pull request May 26, 2023
Alright y'all. After a bunch of conversations about the overall config
and mental model to apply to the project (from the user perspective),
this PR ended up _huge_. It'll be a tough review. I'm sorry 😭

This is a pretty large shift.

Here's a breakdown of the broad strokes:

- The `Plugin` trait was removed from `-types`.
- New traits added: `SenderInput` and `ReceiverOutput` to represent the
  non-svix portions of the dataflow.
- Removed the `-plugin-webhook-receiver` plugin crate.
- moved the http server from the `-plugin-webhook-receiver` crate into
`svix-bridge`.
  - "queue forwarders" into the `-plugin-queue-consumer` crate.
- Renamed the `-plugin-queue-consumer` crate to just `-plugin-queue` (it
now provides both `SenderInput` and `ReceiverOutput` implementation for
the various queue backends.
- all crates etc have been renamed: `s/svix-webhook-bridge/svix-bridge/`


What else, what else, what else...

The example config has been split into 2: one showing `senders` and
another for `receivers`.
The readme has been gutted (but probably needs to be fleshed out a bit
more... again). It felt silly to effectively duplicate the example
configs in code fence blocks a 2nd time.

To sweeten the deal, new test coverage has been added for select
portions of the config parsing as well as for the HTTP receiver stuff.

Both the sender and receiver example configs are now checked in the test
suite to make sure they at least parse without failure. These tests
should be expanded to inspect the actual data, but this diff is so
big... 😭

We didn't have any tests for the HTTP handler execution before this, so
that's very nice to have.
svix-onelson added a commit that referenced this pull request May 30, 2023
Alright y'all. After a bunch of conversations about the overall config
and mental model to apply to the project (from the user perspective),
this PR ended up _huge_. It'll be a tough review. I'm sorry 😭

This is a pretty large shift.

Here's a breakdown of the broad strokes:

- The `Plugin` trait was removed from `-types`.
- New traits added: `SenderInput` and `ReceiverOutput` to represent the
  non-svix portions of the dataflow.
- Removed the `-plugin-webhook-receiver` plugin crate.
- moved the http server from the `-plugin-webhook-receiver` crate into
`svix-bridge`.
  - "queue forwarders" into the `-plugin-queue-consumer` crate.
- Renamed the `-plugin-queue-consumer` crate to just `-plugin-queue` (it
now provides both `SenderInput` and `ReceiverOutput` implementation for
the various queue backends.
- all crates etc have been renamed: `s/svix-webhook-bridge/svix-bridge/`


What else, what else, what else...

The example config has been split into 2: one showing `senders` and
another for `receivers`.
The readme has been gutted (but probably needs to be fleshed out a bit
more... again). It felt silly to effectively duplicate the example
configs in code fence blocks a 2nd time.

To sweeten the deal, new test coverage has been added for select
portions of the config parsing as well as for the HTTP receiver stuff.

Both the sender and receiver example configs are now checked in the test
suite to make sure they at least parse without failure. These tests
should be expanded to inspect the actual data, but this diff is so
big... 😭

We didn't have any tests for the HTTP handler execution before this, so
that's very nice to have.
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