-
Notifications
You must be signed in to change notification settings - Fork 2
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
Re-structure into combined lib & bin project #11
Conversation
Example with There are some valid points to consider:
I didn't find a good practice of embedding file into compiled rust lib, but maybe it is possible with macros. Something like: let lock_file = lock_file!("./schema.lock")?;
let commits = lock_file.commits.unwrap_or(Vec::new());
Indeed, the issue with the client is not simple. Creating yet another client from fishy lib to deploy the schema seems inappropriate. If developer is working with the node programmatically, one already have a client somewhere. Frankly, I don't see a good solution here. After some thought, I believe the existence of such a problem may tell us that the initial separation into library and cli is probably not the right approach. If we decompose the task, all that fishy-lib has to do is to read schema.lock and convert it into [Commit], then fishy-cli do the rest. Not sure it is enough for independent cargo lib and also feels like something that can be used not only for schema deployment. For example - deploy commits from test.lock for node preconfiguration (with schema and published documents) for tests. This functionality (read commits from *.lock) can be placed under p2panda::utils maybe. Then fishy-cli can just use it to read commits and deploy them by its own GraphQL client. It is not looks like best solution but as a possible compromise. This also will eliminate the need to add additional dependency from fishy to project. I think this raises a good question about the availability of a convenient interface for interacting with the Panda node. Perhaps it is worth considering a wrapper around GraphQL with a convenient p2panda-related API? Although the GraphQL protocol is common, the developer must adhere to strict rules for working with the p2panda protocol, and having a client that takes on some of the work (including reading and executing commits from a file for schema deploy) can be a great help. For now we have a missing part:
|
Thanks for your thoughts @Corban-Dallas, really insightful stuff 👍
Yeah, this is a pattern I've been wanting/exploring too. Think the benefits you outline are absolutely desireable. Without adding any functionality to let data = include_str!("schema.lock");
let lock_file: LockFile = toml::from_str(&data).expect("error parsing schema.lock file");
Really agree with this, the most useful struct for developers to get their hands on from
Yes, this is absolutely what we want. It's only a matter of capacity and higher priorities right now. We plan to have a rust crate for this comparable to https://github.com/p2panda/shirokuma. Eventually an abstraction over the query interface as well. |
Didn't know about this way, thanks!
Yeah, sounds reasonable. Even if I proposed this, I am also dissatisfied with this solution. There is simply no suitable place where you can place LockFile for reusing for now.
Sounds cool! If there will be some p2panda client, the publishing entities from lock file can be part of it in the future. May be under feature. |
Seems we talked ourselves out of any changes in this direction 😅 Would be interested to hear from @adzialocha though, before possibly closing this PR and putting it down to good research. |
fishy is fairly powerful (automatically resolving dependency trees, handling key pairs, talking to node via GraphQL etc.) and as you already discussed, maybe that's all not what we actually need even though I also thought we should definitely start with fishy as a lib initially. The thing where I would like to see this currently the most is actually in use aquadoggo::{Configuration, Node};
use p2panda_rs::identity::KeyPair;
let config = Configuration::default();
let key_pair = KeyPair::new();
let node = Node::start(key_pair, config).await;
let data = include_str!("schema.lock"); // super cool, didn't know about that either!
let lock_file: LockFile = toml::from_str(&data).expect("error parsing schema.lock file");
node.migrate(&lock_file).await; We can publish all the data with our internal methods we have inside of our node, no need to go via the GraphQL API here. Later it might be interesting to also add this to a client SDK, but somehow I see migrations currently rather a node concern (it is the starting point). |
Throwing in some more ideas for |
These changes have been taken on by @adzialocha over here: p2panda/aquadoggo#598 Closing this PR. |
When building an application with p2panda an emerging pattern is to deploy required schema to a local node on first start up. This can be done manually with the existing
fishy
cli, but it would be handy if developers could import the required functionality fromfishy
lib and do this initial deployment programmatically.This PR explores splitting
fishy
into alib
module where core functionality lives, and abin
module where the cli application lives (and imports methods from thelib
).Thoughts and comments welcome! Idea was first raised in this issue: #3
Example use [deploy]
Initial thoughts
Client
in this way as this is not exactly a corefishy
concern, and likely something any app will be constructing elsewhere anyway. Open to other ideas here 👍deploy
is that (like infishy
cli) one might want to expose user feedback along the way, as schema are deployed. For this you need closer access to the publishing process.