scalecube / scalecube-services

Microservices library - scalecube-services is a high throughput, low latency reactive microservices library built to scale. It features: API-Gateways, service-discovery, service-load-balancing, the architecture supports plug-and-play service communication modules and features. built to provide performance and low-latency real-time stream-processing
http://scalecube.github.io/
Apache License 2.0
614 stars 106 forks source link

Add new service annotation - `@Method(GET|POST|PUT|...)` #861

Open artem-v opened 1 month ago

artem-v commented 1 month ago

Add support of optional service annotation @Method with value as HTTP method. Must be defined only on methods with annotation @ServiceMethod.

Idea is to support clients who wants to call scalecube service through the HTTP gateway and to support http methods RESTful semantic.

Expected changes

Depends on

https://github.com/scalecube/scalecube-services/issues/856

artem-v commented 1 month ago

Depends on https://github.com/scalecube/scalecube-services/issues/856

aharonha commented 1 month ago

Consider moving the routing strategy from "client" side to discovery layer

artem-v commented 1 month ago

Consider moving the routing strategy from "client" side to discovery layer

Plz elaborate more on this.

aharonha commented 1 month ago

When invoking service to service call, the caller (in this case a service acts like a client) uses the routing strategy (e.g. round-robin, random) based on the annotations, but IMHO the discovery layer should handle it. by that I mean that the service cluster discovery would do the load balancing and routing. This kind of architecture is what k8s calls service while service instances are called pods I remember this part in scalecube from ages ago, and it bothered me back then. When using RESTful approach in a stateless cluster, and the data layer is separated, a client code should not be bothered on which instance to call, but as far as I remember - in the current implementation it does.

And as always it is great to collaborate once again 😄

artem-v commented 1 month ago

And as always it is great to collaborate once again 😄

Yes, Im also glad to see you and your comments (despite that I don't agree with them) : ))

When using RESTful approach in a stateless cluster, and the data layer is separated, a client code should not be bothered on which instance to call

Yes, this is how to it works today, we don't bother which service instance to call. When RESTful support will be implemented on HTTP gateway, it will not be "shift in paradigms" "this change everything", no, it will be just a good extension of HTTP gateway, i.e those who loves RESTful approach will be able to write services in RESTful approach.

but as far as I remember - in the current implementation it does.

No, it never was like that.

by that I mean that the service cluster discovery would do the load balancing and routing.

In scalecube it's different philosophy, we let client to choose load balancing and routing strategies. If he doesn't want to deal with that, fine, round-robin will be used. If default round-robin is a concern, then no problem - implement consistent-hashing, or least-resources load-balancing. I.e philosophy is to - don't centralize decision making, delegate responsibility if it's "delegatable".