burakkose / Quark

Quark is a streaming-first Api Gateway using Akka
Apache License 2.0
12 stars 3 forks source link

Is there a way to update or change the route dynamically? #2

Open YouXiang-Wang opened 7 years ago

burakkose commented 7 years ago

Quark is top on Akka HTTP, but it does not use Akka HTTP routing. We have a simple routing the match services and apply actions to these services. Mostly when you define service("test1"), this will match host:port/service/blabla. Can you please give me more information and simple example so that I can think about it and we can implement.

Thank you for an idea.

YouXiang-Wang commented 7 years ago

@burakkose Thanks for your reply. Basically, a strong gate way is better to support change/add/remove the routing information to route the HTTP request to different response. findServiceFn and patitionFn are the better place to implement the dynamical http routing I think.

BTW, since, it is a gate way, i did not see the code about forward the http request to another http server, where is it?

burakkose commented 7 years ago

Proxying is implemented, but I have not pushed it yet because I am thinking about some features. I will push asap.

Changing routes is a good idea. I will add it after the first version. However, I have some concerns. Currently, If you want to define a route, there is a service action.

Service("id")(operation-actions)

If we want to add routes dynamically, how should we define operation actions for them? By default, It will be proxied only without any operation action. The first approach that I think is defining global service which has operation actions and applies them to entire routes(static and dynamic routes).

If you have a better example(not a teoricital explanation) like a real project that provides this feature or concrete example, please share with me.

YouXiang-Wang commented 7 years ago

@burakkose Actually, I am working on this kind of project. We want to build the Microservice framework using akka in our product.

For defining the route action, I have a thought:

Route action is the actor. Registering the business actor in the gateway, put though the route url to the registered actor. For example:

GET /people/1 ======> Actor /getPeople

For changing route dynamically, we could think about to provide a REST API built-in the framework to change the route table.

burakkose commented 7 years ago

This operation can be done with Akka Stream instead of using Actor. As I mentioned before, registering new route is a simple thing. We can, of course, use rest API for registering. The complicated part is to define operation actions. For example, you have an incoming action which is an authentication controller for the request of service.

Currently, this is done by service("people")(incoming(authentication)) And whenever you call people service, authentication action(or filter) will be applied. If you register a new dynamic route like product service, you should be able to attach incoming actions, or de-attach in case of you do not want to use authentication filter for product service.

I will think about it, and eventually, there will be a feature for it.

YouXiang-Wang commented 7 years ago

I am waiting for your proxy uploaded. :-)

burakkose commented 7 years ago

It will be ready next week :) Unfortunately, I do not have any chance to look in this week.