Java libraries for writing composable microservices

Overview

Apollo

Circle Status Codecov Maven Central License

Status: Archived

⚠️ Apollo is heavily used within Spotify, however, most of its development has recently been done internally leveraging Apollo's module system. Because of this, and the fact that Apollo has very little (if any) use outside Spotify we want to signal this current state to the community by putting the project in archive mode. This means this project will no longer have new features, bug fixes or accept PRs for new features. Apollo development will continue internally in Spotify.

Apollo is a set of Java libraries that we use at Spotify when writing microservices. Apollo includes modules such as an HTTP server and a URI routing system, making it trivial to implement restful API services.

Apollo has been used in production at Spotify for a long time. As a part of the work to release version 1.0.0 we moved the development of Apollo into the open.

There are two main libraries in Apollo:

Apollo API

The apollo-api library is the Apollo library you are most likely to interact with. It gives you the tools you need to define your service routes and your request/reply handlers.

Here, for example, we define that our service will respond to a GET request on the path / with the string "hello world":

public static void init(Environment environment) {
  environment.routingEngine()
      .registerAutoRoute(Route.sync("GET", "/", requestContext -> "hello world"));
}

Note that, for an Apollo-based service, you can see the routes defined for a service by querying /_meta/0/endpoints.

The apollo-api library provides several ways to help you define your request/reply handlers. You can specify how responses should be serialized (such as JSON). Read more about this library in the Apollo API Readme.

Apollo Core

The apollo-core library manages the lifecycle (loading, starting, and stopping) of your service. You do not usually need to interact directly with apollo-core; think of it merely as "plumbing". For more information about this library, see the Apollo Core Readme.

Apollo Test

In addition to the two main Apollo libraries listed above, to help you write tests for your service we have an additional library called apollo-test. It has helpers to set up a service for testing, and to mock outgoing request responses.

Links

Introduction Website
JavaDocs
Maven site

Diagrams

Apollo set-up

Apollo in runtime

Code of conduct

This project adheres to the Open Code of Conduct. By participating, you are expected to honor this code.

Comments
  • allow ServiceHelper to resolve provided instances

    allow ServiceHelper to resolve provided instances

    This needed when writing integration tests to gain access to data access layers and such without code duplication.

    For example.

    final ServiceHelper helper = ServiceHelper.create(new Application(), "application")
            .withModule(new ApplicationModule())
            .withModule(new FakeDatabaseLayer());
    
    helper.start();
    
    final Database database = helper.resolve(Database.class);
    
    opened by udoprog 29
  • Add support for WebSockets

    Add support for WebSockets

    We are soon going to build systems that have a need for real time updates from the servers. Exposing nettys built in support for WebSockets in our routing engine would help us tremendously with that task.

    enhancement wontfix 
    opened by lndbrg 14
  • Add a minimum for reply rate in error ratio calculation

    Add a minimum for reply rate in error ratio calculation

    This fixes an issue where the error-reply-ratio metric will show un-predictable behavior after sites or hosts have been drained without the hosts being restart afterwards.

    opened by johanburatti 13
  • Allocate new groupId and package for Apollo 2.x

    Allocate new groupId and package for Apollo 2.x

    This is suggestion for the next Major version of Apollo.

    Because Apollo is a multi-module project that also exposes an API, there are many opportunities for accidental binary compatibility with 1.x at runtime. This threatens the stability of projects using Apollo, especially in complex environments.

    My suggestion is to introduce a new groupId (com.spotify.apollo2) and move everything into new packages (com.spotify.apollo2). This way, maven dependencies are explicit, and major version compatibility would have to be explicitly addressed instead of by accident.

    enhancement 
    opened by udoprog 11
  • upgrade to okhttp3

    upgrade to okhttp3

    also upgrade okio

    okhttp 2.x is obsolete, and according to https://github.com/square/okhttp/blob/master/CHANGELOG.md#version-300-rc1 there should be no risk to upgrade.

    opened by honnix 10
  • Clarify metadata interface

    Clarify metadata interface

    This is a set of related changes to improve the metadata collection and presentation. Highlights:

    • Move the meta-related interfaces and classes into their own module (except one, IncomingCallsGatherer, which is still in apollo-api-impl).
    • Fix #13 - don't track content type at all.
    • Fix #63 - make the assembly name used configurable.
    • Make it possible for assemblies to define a sort order for client decorators rather than leaving it random. This is necessary to guarantee that outgoing calls will be gathered (if the OutgoingCallsDecorator would end up after the the HttpClientDecorator, it would never be executed).
    opened by pettermahlen 10
  • do not duplicate authorization header

    do not duplicate authorization header

    instead of adding the header without check, reset it in favor of that from incoming request.

    Does this make sense? Do we have use case replying on multiple Authorization header?

    opened by honnix 9
  • Dynamically created metric descriptors

    Dynamically created metric descriptors

    The addition of metrics (#122, #123, #124, #125) introduces dynamically created metrics descriptors - so a new metrics descriptor will be created for previously unknown status codes when they are first encountered. This issue moves a discussion from a comment on #122 to a more visible place.

    enhancement 
    opened by pettermahlen 8
  • Add apollo-entity middleware

    Add apollo-entity middleware

    A set of middleware for working with typed route handlers.


    The gist of it

    class MyApplication {
    
      private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
    
      static void init(Environment environment) {
        MyApplication app = new MyApplication();
        EntityMiddleware entity = EntityMiddleware.forCodec(JacksonEntityCodec.forMapper(OBJECT_MAPPER));
    
        Route<SyncHandler<Response<ByteString>>> route = Route.with(
            entity.direct(Person.class),
            "PUT", "/person/<id>",
            rc -> person -> app.updatePerson(rc.pathArgs().get("id"), person));
    
        // ...
      }
    
      Person updatePerson(String id, Person person) {
        // ...
      }
    }
    

    There's also support for other handler signatures. See README in PR.

    opened by rouzwawi 8
  • fix Maven warnings about missing maven-surefire-plugin version

    fix Maven warnings about missing maven-surefire-plugin version

    The root pom does not define a version for maven-surefire-plugin, which this pom seems to assume.

    [WARNING] Some problems were encountered while building the effective model for com.spotify:apollo-bom:pom:1.8.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ com.spotify:apollo-parent:1.8.1-SNAPSHOT, /root/apollo/pom.xml, line 137, column 21

    opened by mattnworb 7
  • upgrade to okhttp3

    upgrade to okhttp3

    also upgrade okio

    okhttp 2.x is obsolete, and according to https://github.com/square/okhttp/blob/master/CHANGELOG.md#version-300-rc1 there should be no risk to upgrade.

    backport of #220

    opened by honnix 7
Releases(v1.20.4)
I had too much coffee and decided to mirror my actions by writing too many programs in Java.

Raging Coffee Table of Contents Description Running the Programs Extra Dependencies Roadmap Further Reading Known Issues Resources Contributions Descr

Thoroughfare by the Brooks 20 Dec 15, 2022
The Apache Commons CSV library provides a simple interface for reading and writing CSV files of various types.

Apache Commons CSV The Apache Commons CSV library provides a simple interface for reading and writing CSV files of various types. Documentation More i

The Apache Software Foundation 307 Dec 26, 2022
This app is simple and awesome notepad. It is a quick notepad editing experience when writing notes,emails,message,shoppings and to do list.

This app is simple and awesome notepad. It is a quick notepad editing experience when writing notes,emails,message,shoppings and to do list.It is easy to use and enjoy hassle free with pen and paper.

Md Arif Hossain 1 Jan 18, 2022
Section B of Assignment 1. Setup project and collaborate on GitHub by writing test fixtures.

Task Each member (including the team leader) should create a branch (use student number as the branch name) and include a small program in the branch

Quinn Frost 1 Apr 6, 2022
Using this library, and writing a few lines of code, you can manage your own domain objects in ZooKeeper

Using this library, and writing a few lines of code, you can manage your own domain objects in ZooKeeper. It provides CRUD operations and change notifications out of the box.

Sahab 4 Oct 26, 2022
The Download Manager uses a simple yet effective GUI interface built with java’s Swing libraries

The Download Manager uses a simple yet effective GUI interface built with java’s Swing libraries.The use of Swing gives the interface a crisp, modern look and feel. The GUI maintains a list of downloads that are currently being managed.

Manish Kumar Mahawar 2 Jan 2, 2022
Additional plug-ins and extensions for Java's ImageIO using native libraries

NightMonkeys A collection of ImageIO plugins, adding support for newer image formats. NightMonkeys uses the newer Foreign Linker API available in JDK

Gauthier 20 Dec 3, 2022
Saga pattern with Java => order -> payment -> stock microservices are ready to use

Order_Payment_Stock_Saga_Pattern Saga pattern with Java => order -> payment -> stock microservices are ready to use Docker-compose.yaml You can see th

Gurkan İlleez 5 Dec 27, 2022
Tzatziki - Decathlon library to ease and promote Test Driven Development of Java microservices!

Tzatziki Steps Library This project is a collection of ready-to-use Cucumber steps making it easy to TDD Java microservices by focusing on an outside-

Decathlon 32 Dec 15, 2022
A base repo for creating RPC microservices in Java with gRPC, jOOQ, and Maven.

Wenower Core OSX local installation Install Protocol Buffer $ brew install protobuf Install Postgresql and joopc database and user $ brew install pos

Hamidreza Soleimani 1 Jan 9, 2022
A small mod to improve support for architectures and libraries officially unsupported by Minecraft. Mainly targeting Apple Macs using arm processors.

fabric-loom-native-support A small mod to improve support for architectures and libraries officially unsupported by Minecraft. Mainly targeting Apple

FabricMC 5 Oct 17, 2022
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

OpenAPI Generator Master (5.4.x): 6.0.x (6.0.x): ⭐ ⭐ ⭐ If you would like to contribute, please refer to guidelines and a list of open tasks. ⭐ ⭐ ⭐ ‼️

OpenAPI Tools 14.8k Dec 30, 2022
AndroidX Media is a collection of libraries for implementing media use cases on Android

AndroidX Media AndroidX Media is a collection of libraries for implementing media use cases on Android, including local playback (via ExoPlayer) and m

Android Jetpack 311 Jan 1, 2023
CoreLib - Necessary Libraries required to make the Cores work (API 1.0.13)

CoreLib Necessary Libraries required to make the Cores work (API 1.0.13) CoreLib is a collection of necessary libraries required to make the SurvivalC

OP Heroes Development Team 1 Jan 4, 2022
The ByteSkript development kit, including resources for third-party libraries that are not contained within the standard runtime.

ByteSkript Development Kit Todo. The development kit is a set of advanced resources available for library creators. These are not available within the

null 1 Jan 8, 2022
DiscordRPC library that doesn't require any extra native libraries

DiscordRPC library using java 16 sockets on unix-like systems This is both good and bad, it's good because the only native library it needs is the sta

Nep Nep 4 Oct 8, 2022
OpenAPI JSON Schema Generator allows auto-generation of API client libraries with a focus on JSON schema given an OpenAPI Spec

OpenAPI JSON Schema Generator IMPORTANT: before the first release, one will need to build the project locally to use the enhancements, bug fixes in th

OpenAPI Tools 5 Dec 31, 2022
First experiments to try to render the Doom WAD maps using only standard libraries. Test 004 - https://youtu.be/-6mePgg7gXE

JavaDoomWADMapRendererTests Test 001 (07/set/2022) - https://youtu.be/MpY0PICdcwM First experiments to try to render the Doom WAD maps using only stan

Leo 6 Oct 17, 2022
How To Implement Fault Tolerance In Microservices Using Resilience4j

springboot-resilience4j-demo How To Implement Fault Tolerance In Microservices Using Resilience4j? Things todo list: Clone this repository: git clone

Hendi Santika 4 Mar 30, 2022