etcd

package module
v0.0.0-...-ff4871a Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

registry-etcd (This is a community driven project)

Some application runtime use etcd for service discovery.

How to use with Kitex server?

import (
    ...
    "github.com/cloudwego/kitex/pkg/rpcinfo"
    "github.com/cloudwego/kitex/server"
    etcd "github.com/sun-fight/registry-etcd"
    ...
)

func main() {
    ...
    r, err := etcd.NewEtcdRegistry([]string{"127.0.0.1:2379"}) // r should not be reused.
    if err != nil {
        log.Fatal(err)
    }
    // https://www.cloudwego.io/docs/tutorials/framework-exten/registry/#integrate-into-kitex
    server, err := echo.NewServer(new(EchoImpl), server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: "echo"}, server.WithRegistry(r)))
    if err != nil {
        log.Fatal(err)
    }
    err = server.Run()
    if err != nil {
        log.Fatal(err)
    }
    ...
}

How to use with Kitex client?

import (
    ...
    "github.com/cloudwego/kitex/client"
    etcd "github.com/sun-fight/registry-etcd"
    ...
)

func main() {
    ...
    r, err := etcd.NewEtcdResolver([]string{"127.0.0.1:2379"})
    if err != nil {
        log.Fatal(err)
    }
    client, err := echo.NewClient("echo", client.WithResolver(r))
    if err != nil {
        log.Fatal(err)
    }
    ...
}

More info

See example.

Compatibility

Compatible with etcd server v3.

maintained by: lizheming

Documentation

Overview

Package etcd resolver

Package etcd resolver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEtcdRegistry

func NewEtcdRegistry(endpoints []string) (registry.Registry, error)

NewEtcdRegistry creates a etcd based registry.

func NewEtcdRegistryWithAuth

func NewEtcdRegistryWithAuth(endpoints []string, username, password string) (registry.Registry, error)

NewEtcdRegistryWithAuth creates a etcd based registry with given username and password.

func NewEtcdRegistryWithAuthTimeout

func NewEtcdRegistryWithAuthTimeout(endpoints []string, username, password string, timeout func()) (registry.Registry, error)

func NewEtcdRegistryWithTimeout

func NewEtcdRegistryWithTimeout(endpoints []string, timeout func()) (registry.Registry, error)

NewEtcdRegistry creates a etcd based registry.

func NewEtcdResolver

func NewEtcdResolver(endpoints []string) (discovery.Resolver, error)

NewEtcdResolver creates a etcd based resolver.

func NewEtcdResolverWithAuth

func NewEtcdResolverWithAuth(endpoints []string, username, password string) (discovery.Resolver, error)

NewEtcdResolverWithAuth creates a etcd based resolver with given username and password.

Types

This section is empty.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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