Git Product home page Git Product logo

smallrye-stork's Introduction

SmallRye Stork

Maven javadoc License badge Quality Gate Status

SmallRye Stork, Stork, in short, is a Service Discovery and Client-Side Load Balancer framework.

Main features

  • Extensible service discovery mechanisms

  • Built-in support for Consul and Kubernetes

  • Customizable client load-balancing strategy

  • API and managed approaches

  • Quarkus integration, but can be used in any environment

  • Imperative and Reactive

Example

Let’s imagine you use Consul. Consul stores the list of service instances you have and lets you locate them.

Stork bridges your application and Consul and lets you retrieve the services stored in Consul and select the most appropriate one:

Stork.initialize();                                                 // (1)
Stork stork = Stork.getInstance();                                  // (2)
Service service = stork.getService("my-service");                   // (3)
ServiceInstance instance = service.selectServiceInstance()          // (4)
    .await().atMost(Duration.ofSeconds(1));
String url = "http://" + instance.getHost() + instance.getPort();   // (5)
  1. Initializes Stork - you need to do that only once.

  2. Gets the Stork instance.

  3. Gets the Service object for my-service.

  4. Retrieves the service instance for my-service. This performs a lookup in Consul and a selection using a load-balancer.

  5. Builds your URL.

That example uses the programmatic API. When integrated into the framework, all these steps can be omitted, and you only need to configure the application:

stork.my-service.service-discovery.type=consul            # (1)
stork.my-service.load-balancer.type=least-response-time   # (2)

hello/mp-rest/url=stork://my-service/hello           # (3)
  1. Configures that the my-service service uses Consul as service discovery backend

  2. Configures the load balancer for my-service

  3. Uses the stork scheme and indicates which service is targeted. When accessed, it will select the service instance using Stork.

Contributing

Check the contribution guide to get build and contribution instructions.

Sponsors

Stork is part of the SmallRye project. Red Hat sponsors the development of this project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.