quarkiverse / quarkus-couchbase

Couchbase is an award-winning distributed NoSQL cloud database.
Apache License 2.0
7 stars 6 forks source link
couchbase quarkus-extension
# Quarkus Couchbase


[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) [![Version](https://img.shields.io/maven-central/v/io.quarkiverse.couchbase/quarkus-couchbase?logo=apache-maven&style=flat-square)](https://search.maven.org/artifact/io.quarkiverse.couchbase/quarkus-couchbase) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0) [![Build](https://github.com/quarkiverse/quarkus-couchbase/actions/workflows/build.yml/badge.svg)](https://github.com/quarkiverse/quarkus-couchbase/actions/workflows/build.yml)

Integrates Couchbase into Quarkus.

This extension is currently in beta status. It supports:

Please try it out and provide feedback, ideas and bug reports on Github.

Native Image

[!IMPORTANT] While the extension compiles natively, there are known issues with the produced runner which we are actively working to resolve.

Usage

Add it to your project:

<dependency>
  <groupId>io.quarkiverse.couchbase</groupId>
  <artifactId>quarkus-couchbase</artifactId>
  <version>1.0.0.Beta2</version>
</dependency>

Provide the Couchbase configuration in application.properties:

quarkus.couchbase.connection-string=localhost
quarkus.couchbase.username=username
quarkus.couchbase.password=password

To disable TestContainers, add:

quarkus.devservices.enabled=false

Now you can @Inject a Couchbase Cluster into your project:

@Path("/couchbase")
public class TestCouchbaseResource {
    @Inject
    Cluster cluster;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/test")
    public String run() {
        // Get a reference to a particular Couchbase bucket and its default collection
        var bucket = cluster.bucket("travel-sample");
        var collection = bucket.defaultCollection() ;

        // Upsert a new document
        collection.upsert("test", JsonObject.create().put("foo", "bar"));

        // Fetch and print a document
        var doc = bucket.defaultCollection().get("test");
        System.out.println("Got doc " + doc.contentAsObject().toString());

        // Perform a N1QL query
        var queryResult = cluster.query("select * from `travel-sample` where url like 'http://marriot%' and country = 'United States';");

        queryResult.rowsAsObject().forEach(row -> {
            System.out.println(row.toString());
        });

        return "success!";
    }
}

And test http://localhost:8080/couchbase/test.

Limitations

In this a beta release the configuration options are limited to the three shown above.
This means that a Couchbase cluster configured securely and requiring TLS or a client or server certificate, cannot currently be connected to.

License

All the files under nettyhandling directories, both in the runtime and deployment modules are taken as-were or modified from the official netty extension. Couchbase does not intend copyright infringement or claim ownership over these files or their content.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Graham Pople
Graham Pople

💻 🚧
Emilien Bevierre
Emilien Bevierre

💻 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!