Golang client

This page describes using the Lenses Golang client.

Installation

go get -u github.com/lensesio/lenses-go

Getting started

import "github.com/lensesio/lenses-go"

// Prepare authentication using raw Username and Password.
auth := lenses.BasicAuthentication{Username: "user", Password: "pass"}


#auth := lenses.KerberosAuthentication{
#    ConfFile: "/etc/krb5.conf",
#    Method:   lenses.KerberosWithPassword{
#        Realm: "my.realm or default if empty",
#        Username: "user",
#        Password: "pass",
#    },
#}

#auth := lenses.KerberosAuthentication{
#    ConfFile: "/etc/krb5.conf",
#    Method:   lenses.KerberosWithKeytab{KeytabFile: "/home/me/krb5_my_keytab.txt"},
#}

#auth := lenses.KerberosAuthentication{
#    ConfFile: "/etc/krb5.conf",
#    Method:   lenses.KerberosFromCCache{CCacheFile: "/tmp/krb5_my_cache_file.conf"},
#}

Configuration

// Prepare the client's configuration based on the host and the authentication above.
currentConfig := lenses.ClientConfig{Host: "domain.com", Authentication: auth, Timeout: "15s", Debug: true}

// Creating the client using the configuration.
client, err := lenses.OpenConnection(currentConfig)
if err != nil {
    // handle error.
}

Usage

All lenses-go#Client methods return a typed value based on the call and an error as second output to catch any errors coming from backend or client, forget panics.

topics, err := client.GetTopics()
if err != nil {
    // handle error.
}

// Print the length of the topics we've just received from our Lenses Box.
print(len(topics))

Last updated

Logo

2024 © Lenses.io Ltd. Apache, Apache Kafka, Kafka and associated open source project names are trademarks of the Apache Software Foundation.