Skip to content

Conversation

@jcrossley3
Copy link
Contributor

To address #130

@jcrossley3 jcrossley3 marked this pull request as ready for review June 18, 2021 02:00
@slinkydeveloper
Copy link
Member

slinkydeveloper commented Jun 21, 2021

Ok the first thing I would do is to split this PR into several PRs, one per submodule. Also don't remove the old packages now, we can do that later.

@slinkydeveloper
Copy link
Member

You also need to sign the DCO :)

@jcrossley3
Copy link
Contributor Author

You also need to sign the DCO :)

I signed all but the one I need help with. I can do that when I figure out how to fix it.

@jcrossley3
Copy link
Contributor Author

Ok the first thing I would do is to split this PR into several PRs, one per submodule. Also don't remove the old packages now, we can do that later.

So you prefer 1-PR-per-submodule to 1-commit-per-submodule as I currently have it? I can do that, but I'm curious why that's better? Once I back out the deletion of the existing packages and FromRequest impl, we'll only be left with the 4 submodule commits in this PR. Is that better than 4 PR's with one commit each?

@jcrossley3
Copy link
Contributor Author

jcrossley3 commented Jun 21, 2021

Ok, I just force-pushed changes that leave the old workspace dirs intact and don't add the FromRequest impl. Just one commit for each submodule feature. I changed the ce- feature prefix to cloudevents-, and addressed the test/lint failures as well.

Because tests are replicated in the parent workspace now, each will run twice for cargo test --workspace --all-features

@jcrossley3 jcrossley3 changed the title [WIP] Refactor runtime crates into feature-guarded modules Refactor runtime crates into feature-guarded modules Jun 21, 2021
Copy link
Member

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

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

Can you try to run locally cargo doc --open --all-features to see if this breaks the doc build? You should also try cargo publish --dry-run to see if any publish check breaks (although I'm not sure you can do that without logging in)

use std::collections::HashMap;
use std::str::FromStr;

macro_rules! unwrap_optional_header {
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but maybe for future refactorings: a lot of these macros are copy paste, because the APIs are practically the same even if their names are different, so it would be nice to find a way to unify them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in #146

@slinkydeveloper
Copy link
Member

slinkydeveloper commented Jun 23, 2021

Another thing I'm not 100% sure of is how this is gonna play out with our existing CI config, with our matrix of different targets... For example, the actix feature is not supposed to build with wasm. I might be wrong, but it seems to me that the integrations are not tested anymore with this PR, without modifying the existing github actions config.

@jcrossley3
Copy link
Contributor Author

Can you try to run locally cargo doc --open --all-features to see if this breaks the doc build? You should also try cargo publish --dry-run to see if any publish check breaks (although I'm not sure you can do that without logging in)

Done. Fixed several broken links. I only tested the publish from the root and it seemed fine, abandoning only because of --dry-run and without requiring me to log in.

@jcrossley3
Copy link
Contributor Author

Another thing I'm not 100% sure of is how this is gonna play out with our existing CI config, with our matrix of different targets... For example, the actix feature is not supposed to build with wasm. I might be wrong, but it seems to me that the integrations are not tested anymore with this PR, without modifying the existing github actions config.

I added an --all-features to every step that had --workspace. This essentially runs all the tests twice. When we delete the workspace dirs, we can remove the --workspace option in the actions, too.

As far as the wasm32 build goes, I added the cloudevents-reqwest feature to the args, but I'm unable to see this working locally. I can't get past the following:

[jim@localhost reqwest-wasm-example]$ npm run serve

> @ serve /home/jim/src/rust/sdk-rust/example-projects/reqwest-wasm-example
> webpack-dev-server

🧐  Checking for wasm-pack...

ℹ️  Installing wasm-pack 

ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /home/jim/src/rust/sdk-rust/example-projects/reqwest-wasm-example
✖ 「wdm」: Error: Rust compilation.
    at ChildProcess.<anonymous> (/home/jim/src/rust/sdk-rust/example-projects/reqwest-wasm-example/node_modules/@wasm-tool/wasm-pack-plugin/plugin.js:210:16)
    at ChildProcess.emit (events.js:376:20)
    at maybeClose (internal/child_process.js:1055:16)
    at Socket.<anonymous> (internal/child_process.js:441:11)
    at Socket.emit (events.js:376:20)
    at Pipe.<anonymous> (net.js:673:12)

@slinkydeveloper
Copy link
Member

As far as the wasm32 build goes, I added the cloudevents-reqwest feature to the args, but I'm unable to see this working locally. I can't get past the following:

Mhhh that error is weird, perhaps the js deps needs to be updated

Conditionally compile actix module when enabled

Mostly straightforward, though I don't particularly love that dev-deps
can't be optional: rust-lang/cargo#1596

Signed-off-by: Jim Crossley <[email protected]>
Conditionally compile reqwest module when enabled

This resulted in a naming conflict between my desired feature name,
"reqwest", and the optional dependency itself. So I adopted the
convention of prefixing the features with "cloudevents-".

Signed-off-by: Jim Crossley <[email protected]>
Conditionally compile rdkafka module when enabled

Signed-off-by: Jim Crossley <[email protected]>
Conditionally compile warp module when enabled

Signed-off-by: Jim Crossley <[email protected]>
Verified `cargo doc --all-features` works

Signed-off-by: Jim Crossley <[email protected]>
For the wasm32 build, we replace --package <<redundant>> with --features cloudevents-reqwest

Signed-off-by: Jim Crossley <[email protected]>
@jcrossley3
Copy link
Contributor Author

As far as the wasm32 build goes, I added the cloudevents-reqwest feature to the args, but I'm unable to see this working locally. I can't get past the following:

Mhhh that error is weird, perhaps the js deps needs to be updated

Didn't help. I get the same error on master, so I don't think this PR broke it. Besides, all the checks are passing. ;)

I think I've addressed all your concerns. Let me know if you need anything else!

@slinkydeveloper slinkydeveloper added the enhancement New feature or request label Jun 25, 2021
@slinkydeveloper slinkydeveloper added this to the 0.4 milestone Jun 25, 2021
@slinkydeveloper slinkydeveloper merged commit 362492f into cloudevents:master Jun 25, 2021
jcrossley3 added a commit to jcrossley3/sdk-rust that referenced this pull request Jun 28, 2021
Now that we've refactored the protocol bindings from crates to
feature-guarded modules (PR cloudevents#131), we can remove the workspaces for
those crates.

Signed-off-by: Jim Crossley <[email protected]>
slinkydeveloper pushed a commit that referenced this pull request Jun 30, 2021
Now that we've refactored the protocol bindings from crates to
feature-guarded modules (PR #131), we can remove the workspaces for
those crates.

Signed-off-by: Jim Crossley <[email protected]>
@jcrossley3 jcrossley3 deleted the single-crate branch July 7, 2021 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants