consulcli

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 3 Imported by: 0

README

consulcli

Connect to the consul service client.

Example of use

    import "gitee.com/the_sun_light/common_pkg/consulcli"

    addr := "192.168.3.37:8500"

    // Way 1: setting parameters
    cli, err := consulcli.Init(addr,
        consulcli.WithWaitTime(time.Second*5),
        // consulcli.WithDatacenter(""),
    )

    // Way 2: setting up api.Config
    cli, err = Init("", consulcli.WithConfig(&api.Config{
        Address:    addr,
        Scheme:     "http",
        WaitTime:   time.Second * 5,
        Datacenter: "",
    }))

Documentation

Overview

Package consulcli is connecting to the consul service client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(addr string, opts ...Option) (*api.Client, error)

Init connecting to the consul service Note: If the WithConfig(*api.Config) parameter is set, the addr parameter is ignored!

Types

type Option

type Option func(*options)

Option set the consul client options.

func WithConfig

func WithConfig(c *api.Config) Option

WithConfig set consul config

func WithDatacenter

func WithDatacenter(datacenter string) Option

WithDatacenter set datacenter

func WithScheme

func WithScheme(scheme string) Option

WithScheme set scheme

func WithToken

func WithToken(token string) Option

WithToken set token

func WithWaitTime

func WithWaitTime(waitTime time.Duration) Option

WithWaitTime set wait time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL