Comments (6)
Probably a trait with the datatypes, and perhaps a a feature flag to only import the API definition without the actual server implementation (that's how I do it when using gRPC). Both the server and the client can depend on a single shared trait.
Server crate
pub trait API {
fn get() -> Foo;
}
#[cfg(feature=server)]
mod server {
pub struct Server {}
impl API for Server ...
}
Pallet crate
use server::API;
struct Client;
impl API for Client {
# pallet offchain worker logic here.
}
from composable.
I'd move the interface definition to the server implementation, and import that into the offchain worker. Where is the price-feed server defined?
from composable.
When you say importing that to the offchain worker. Do you mean importing the whole project as a dependency? The only "interface" we currently have is the http endpoint along with the JSON schema expected by the offchain worker (just wrapping the price), here in the server
from composable.
Ok that makes sense :)!
from composable.
At least, I really like this pattern :) Since the server is kind of in charge of the API spec, it is logical to define the interface there as well. But now you do get a well defined API. It also allows for easy embedding in over different protocols.
tower plays really nicely with different frameworks and protocols too. If only we had async traits already, it'd be perfect.
from composable.
Of course this pattern is nice :).
It reminds me of Servant in Haskell, were we share the API so that you end up being able to automatically derive the client.
from composable.
Related Issues (20)
- feat(mantis): run and resonably test python solver blackbox HOT 3
- dep(osmosis): contact indexer does not work anymore HOT 1
- dep(neutron): decision on optimizing neutron cw contacts for CVM (0.86 USD per program gas) HOT 1
- chore(devnet): build assets chain using official steps to speed up ci
- chore(composble-cosmos): deploy cvm HOT 2
- decision(cvm): reduced size CVM feature flag HOT 2
- research(cvm): remove executor ability to run code, but use it as only funds owner thing HOT 3
- feat(blackbox): install SCIP solver into project HOT 1
- feat(lsd-ledger-update): add feeless ledger staking update once per relay chain era. HOT 6
- feat(mantis): communicate with Octeract HOT 1
- feat(mantis): systematic research of solver limits and constraints HOT 2
- feat(mantis): normalize/downscale all reserves/inputs depending on oracles price HOT 3
- feat(cvm): CVM dummy data from API for testing HOT 2
- ci(e2e): tests fails, integrated health check tooling to know why HOT 3
- release(mantis): blackbox (solver algorithm) task list HOT 1
- release(mantis): solver v2 with cross chain HOT 1
- feat: CVM for Solana HOT 5
- feat(cvm): bot which generates CVM registry mappings from chains/exchnages/channels/tokens
- MANTIS Season 2 #1376
- MANTIS Season 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from composable.