/couchbase-capi-server

OBSOLETE, NO LONGER MAINTAINED. An abstract Java HTTP server for pretending to be a Couchbase Server node.

Primary LanguageJava

Couchbase CAPI Server

This project implements an HTTP server capable of responding to Couchbase and CAPI requests.

Couchbase Requests supported:

  • /pools (GET)
  • /pools/default (GET)
  • /pools/default/buckets (GET)
  • /pools/default/buckets/{bucket} (GET)

CAPI Requests supported:

  • /{database} (HEAD, GET)
  • /{database}/{docid} (GET)
  • /{database}/_ensure_full_commit (POST)
  • /{database}/_revs_diff (POST)
  • /{database}/_bulk_docs (POST)

This project does not come with an actual implementation of the behaviors behind these actions. Instead two interfaces are exposed:

  • CouchbaseBehavior
  • CAPIBehavior

Users of this library will provide their own implemenations of these interfaces to deliver the desired behavior.

Building

This project is built using Maven.

mvn install 

Using

  • Implement your own CouchbaseBehavior
    public class MyCustomCouchbaseBehavior implements CouchbaseBehavior { ... }
  • Implement your own CAPIBehavior
    public class MyCustomCAPIBehavior implements CAPIBehavior { ... }
  • Create instances of #1 and #2
    CouchbaseBehavior couchbaseBehavior = new MyCustomCouchbaseBehavior();
    CAPIBehavior capiBehavior = new MyCustomCAPIBehavior();
  • Start a CAPIServer
    CAPIServer capiServer = new CAPIServer(capiBehavior, couchbaseBehavior);
    capiServer.start();

By default this will start a server bound to 0.0.0.0 on an ephemeral port. If you'd like to bind to a different interface or a particular port, there are alternate constructors available.