-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from helsing-ai/mara/fs-deps
Local Dependencies
- Loading branch information
Showing
62 changed files
with
648 additions
and
110 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
## Local Dependencies | ||
|
||
When working on larger projects or in monorepo projects setups you may find | ||
yourself in the situation to consume a locally defined buffrs project. | ||
|
||
Imagine the following project setup: | ||
|
||
``` | ||
mono | ||
├── build.rs | ||
├── Cargo.toml | ||
├── Proto.toml | ||
├── Proto.toml | ||
├── proto | ||
| └── mono.proto | ||
└── src | ||
└── main.rs | ||
``` | ||
|
||
In this scenario the buffrs project for `mono-api` and the cargo project for | ||
the `mono-server` are setup in the very same directory, which is totally fine | ||
as long as this server does not require other buffrs api packages to be | ||
compiled! | ||
|
||
#### Problem | ||
|
||
Adding a dependency on other (unrelated api packages to `mono-api`) is | ||
complicated in the above scenario because its not clear to buffrs whether you | ||
are trying to reuse third party api definitions for your api or just wanting to | ||
install protos for compilation. | ||
|
||
Hence buffrs will throw you an error if you try to publish an api package with | ||
dependencies on other apis! | ||
|
||
``` | ||
Error: × failed to publish `mono-api` to `http://<registry-uri>/<repository>` | ||
╰─▶ depending on API packages is not allowed | ||
``` | ||
|
||
#### Solution | ||
|
||
Gladly buffrs offers a builtin solution for this! You can separate the | ||
`mono-api` buffrs package (used to publish your api) from the `mono-server` | ||
buffrs projects (used to install protos for compiling the server). | ||
|
||
A monorepo setup here could look like this: | ||
|
||
``` | ||
mono | ||
├── mono-api | ||
| ├── Proto.toml | ||
| └── proto | ||
| └── mono.proto | ||
└── mono-server | ||
├── build.rs | ||
├── Cargo.toml | ||
├── Proto.toml | ||
├── proto | ||
| └── vendor | ||
└── src | ||
└── main.rs | ||
``` | ||
|
||
Where `mono/mono-api/Proto.toml` has this content: | ||
|
||
``` | ||
edition = "0.9" | ||
[package] | ||
type = "api" | ||
name = "mono-api" | ||
version = "0.1.0" | ||
``` | ||
|
||
And `mono/mono-server/Proto.toml` has this content: | ||
|
||
``` | ||
edition = "0.9" | ||
[dependencies] | ||
mono-api = { path = "../api" } | ||
third-party-api = { version = "=1.0.0", repository = "some-repo", registry = "http://..." } | ||
``` | ||
|
||
This enables you to: | ||
|
||
- Independently publish `mono-api` using `buffrs publish` / `buffrs package` | ||
- Independently declare dependencies for `mono-server` | ||
|
||
#### Caveats | ||
|
||
Please note that projects containing any local dependencies can not be | ||
published anymore. The ability to declare local filesystem dependencies is | ||
mainly useful for the above scenario where you want to install buffrs packages | ||
for your server from different locations on the filesystem (monorepo, git | ||
submodules etc). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.