Skip to content
immudb docker run -d --net host -it --name immudb codenotary/immudb:latest

Health Check

HealthCheck return an error if immudb status is not ok.

Go

 1package main
 2
 3import (
 4	"context"
 5	"log"
 6
 7	immudb "github.com/codenotary/immudb/pkg/client"
 8)
 9
10func main() {
11	opts := immudb.DefaultOptions().
12		WithAddress("localhost").
13		WithPort(3322)
14
15	client := immudb.NewClient().WithOptions(opts)
16	err := client.OpenSession(
17		context.TODO(),
18		[]byte(`immudb`),
19		[]byte(`immudb`),
20		"defaultdb",
21	)
22	if err != nil {
23		log.Fatal(err)
24	}
25
26	defer client.CloseSession(context.TODO())
27
28	err = client.HealthCheck(context.TODO())
29	if err != nil {
30		log.Fatal(err)
31	}
32}

Java

 1package io.codenotary.immudb.helloworld;
 2
 3import io.codenotary.immudb4j.*;
 4
 5public class App {
 6
 7    public static void main(String[] args) {
 8        FileImmuStateHolder stateHolder = FileImmuStateHolder.newBuilder()
 9                    .withStatesFolder("./immudb_states")
10                    .build();
11
12        ImmuClient client = ImmuClient.newBuilder()
13                    .withServerUrl("127.0.0.1")
14                    .withServerPort(3322)
15                    .withStateHolder(stateHolder)
16                    .build();
17
18        client.login("immudb", "immudb");
19
20        boolean isHealthy = immuClient.healthCheck();
21    }
22
23}

.NET

The following code snippets show how to invoke the healthcheck endpoint:

1    Immuclient immuClient = new ImmuClient("localhost", 3322);
2    await immuClient.Open("immudb", "immudb", "defaultdb");
3
4    bool result = await immuClient.HealthCheck();
5    Console.WriteLine(result);

Python

 1from immudb import ImmudbClient
 2
 3URL = "localhost:3322"  # immudb running on your machine
 4LOGIN = "immudb"        # Default username
 5PASSWORD = "immudb"     # Default password
 6DB = b"defaultdb"       # Default database name (must be in bytes)
 7
 8def main():
 9    client = ImmudbClient(URL)
10    client.login(LOGIN, PASSWORD, database = DB)
11    check = client.healthCheck()    # Returns bool
12    print(check)                    # True
13
14if __name__ == "__main__":
15    main()

Node.js

 1import ImmudbClient from 'immudb-node'
 2
 3const IMMUDB_HOST = '127.0.0.1'
 4const IMMUDB_PORT = '3322'
 5const IMMUDB_USER = 'immudb'
 6const IMMUDB_PWD = 'immudb'
 7
 8const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
 9
10(async () => {
11	await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
12
13	await cl.health()
14})()

Others

If you’re using another development language, please refer to the immugw option.

Edit this page on GitHub Last updated