discovery

package module
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 28

README

discovery-go

This library programmatically finds endpoints for dependencies. Similar to discovery-node and disocvery-python.

See Service Discovery for more details.

API

Godoc Documentation

Examples
gearmanAdminURLString, err := discovery.URL("gearman-admin", "http")
if err != nil {
    log.Fatal("ERROR: " + err.Error())
}

stokedHostPort, err := discovery.HostPort("stoked", "thrift")
if err != nil {
    logger.Fatal("ERROR: " + err.Error())
}

stokedHost, err := discovery.Host("stoked", "thrift")
if err != nil {
    logger.Fatal("ERROR: " + err.Error())
}

stokedPort, err := discovery.Port("stoked", "thrift")
if err != nil {
    logger.Fatal("ERROR: " + err.Error())
}
Implementation Details

Currently, discovery-{go,node,python} looks for environment variables with the following format:

SERVICE_{SERVICE_NAME}_{EXPOSE_NAME}_{PROTO,HOST,PORT}

These environment variables are autogenerated by fab and catapult during app deployment. Three env-vars are created for each app listed in the dependencies section of caller's launch yaml.

For example, if an app lists district-authorizations as a dependency, fab and catapult will generate this env-vars triplet:

SERVICE_DISTRICT_AUTHORIZATIONS_HTTP_PROTO = "http"
SERVICE_DISTRICT_AUTHORIZATIONS_HTTP_HOST = "district-authorizations.ops.clever.com"
SERVICE_DISTRICT_AUTHORIZATIONS_HTTP_PORT = "80"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Host

func Host(service, name string) (string, error)

Host finds the specified host for a service based off of the service's name and which interface you are accessing. Values are found in environment variables fitting the scheme: SERVICE_{SERVICE NAME}_{INTERFACE NAME}_HOST.

func HostPort

func HostPort(service, name string) (string, error)

HostPort finds the specified host:port combo for a service based off of the service's name and which interface you are accessing. Values are found in environment variables fitting the scheme: SERVICE_{SERVICE NAME}_{INTERFACE NAME}_{PROTO,HOST,PORT}.

func Port

func Port(service, name string) (string, error)

Port finds the specified port for a service based off of the service's name and which interface you are accessing. Values are found in environment variables fitting the scheme: SERVICE_{SERVICE NAME}_{INTERFACE NAME}_PORT.

func Proto

func Proto(service, name string) (string, error)

Proto finds the specified protocol for a service based off of the service's name and which interface you are accessing. Values are found in environment variables fitting the scheme: SERVICE_{SERVICE NAME}_{INTERFACE NAME}_PROTO.

func ProtoHost added in v1.7.0

func ProtoHost(service, name string) (string, error)

ProtoHost finds the specified proto:host combo for a service based off of the service's name and which interface you are accessing. Values are found in environment variables fitting the scheme: SERVICE_{SERVICE NAME}_{INTERFACE NAME}_{PROTO,HOST,PORT}.

func URL

func URL(service, name string) (string, error)

URL finds the specified URL for a service based off of the service's name and which interface you are accessing. Values are found in environment variables fitting the scheme: SERVICE_{SERVICE NAME}_{INTERFACE NAME}_{PROTO,HOST,PORT}.

Types

This section is empty.

Jump to

Keyboard shortcuts

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