Comments (8)
Haha, we actually did exactly that in our web api project))
from orleankka.
From my experience, the simplest way to implement such a generic RPC endpoint would be tunneling.
POST /api/{grainInterface}/{grainId}/{grainMethod}
BODY
{
"param1": "foo",
"param2": "bar"
}
This is easy to bind with Orleans's native method-based interfaces but in our case {grainMethod}
should be specifying message type. Something like:
POST /api/MyApp.MyNamespace.InventoryItem/IT-1234/MyApp.MyNamespace.DeactivateInventoryItem
BODY
{
"param1": "foo",
"param2": "bar"
}
This would require some kind of pre-scanning or pre-registering of all known message types. We use special contract binder and mark all of our custom message classes with special attribute (ie [BindingContract("MentionStream.Projections.StartReplicating")]
). That gives us a layer of indirection (we bind routes to contract ids) and a simple way to find and register all of the messages by scanning the assembly. We use strongly-typed actors and ActorMessage<TActor, TResult>
almost everywhere and that enables some preliminary validation on the side of http api .
P.S. The above could be complemented with GET
endpoint, which is just a simplified way of invoking POST
for methods (messages) that don't have any required fields to fill in.
GET /api/{grainInterface}/{grainId}/{grainMethod}
from orleankka.
I explored a bit Cedar and had some idea on how to implement this.
First I don't like an idea of having a single URL for commands like POST /api/commands
so I would go with something like
PUT /api/{targetGrainType}/{grainId}/actions/{commandType}/{commandId}
or it could be
POST /api/{targetGrainType}/{grainId}/actions/
but with a required header of what kind of command is it and if no id provided it would redirect to newly generated command id via 307 response (like https://eventstore.org/docs/http-api/creating-writing-a-stream/index.html)
graintype/commandTypes should not be exactly .net types, but could be annotations or a routing table.
this way it should be easier to have 1 to 1 matching of a URI to actor path and HTTP body to actor message.
Some things which are fuzzy for me.
- The behavior of a read command. Should errors be saved? if yes, should they be overridden by the second/third attempt?
- Implementation details. Each command could be a single grain or an Orleannkka middleware
from orleankka.
So you don't build an inderection layer, but send messages straight to grains if they pass validation?
Do you distinguish queries/commands?
from orleankka.
In tunneling (REST0), cmd/queries are not distinguished. It’s all POST with result. It maps to always send messages to actors via Ask.
Yes, I do straightforward mapping between routes and actors/messages and then simply use Ask to invoke
from orleankka.
This is just an internal endpoint, of course. We don’t expose actors over http as is.
from orleankka.
it makes more sense then. I was thinking of building something like https://servicestack.net/ routing with security/validation middlewares.
Should be a nice exercise at least :)
from orleankka.
Maybe Brighter could be used also.
from orleankka.
Related Issues (20)
- Document F# bugger or add a startup check HOT 1
- Create template for dotnet cli tool HOT 4
- Orleans AlwaysInterleave question HOT 3
- Missing ServiceId of ClusterOptions in F# samples and Docs HOT 1
- Storage provider issue HOT 1
- F# + recieve message DU instead of object. HOT 3
- Orleankka + Dashboard \n Dashboard can't see methods information
- What should I do to call orleankka actor from orleans silo? HOT 5
- Is ImplicitStreamSubscription supported? HOT 5
- .Net Core 3 Preview 6 Idiomatic Example HOT 4
- Auto.Interfaces assembly generated in wrong folder HOT 4
- Undefined UseOrleankka HOT 1
- Is this project active? HOT 4
- Feature request: StreamRefMiddleware HOT 3
- Allow IActorGrain and GrainWithStringKey in inherited interface
- Nake.bat uses version of EventStore no longer available
- Missing NuGet for Orleankka.TestKit version 7.0.0 HOT 2
- ActorPath changes between ActorRef and ActorGrain HOT 4
- StreamRef and ImplicitStreamSubscription issues HOT 1
- Impact of Orleans 7.0 Stream Changes to Memory Stream / SMS
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 orleankka.