envoyds

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

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

Go to latest
Published: May 7, 2017 License: MIT Imports: 18 Imported by: 0

README

envoyds

ykevinc/envoyds is a Golang implementation of Lyft/Discovery, a discovery service provides the REST interface for querying and registering service in microservice infrastructure. It is to be pluginable as the service discovery solution for Envoy.

Discovery service settings

The settings are controlled by envoyds.conf file. To loaded a different file than one from the current workspace, provide the file path as first command line argument. (i.e. envoyds [<optional-config-path>])

"envoyds.environment" = "dev"

"envoyds.port" = 8000

"envoyds.redis.host" = "localhost"

"envoyds.redis.port" = 6379

How to build

  1. glide is used to manage Go dependencies. Please make sure glide is in your PATH before you attempt to build.
  2. cd envoyds
  3. go build envoyds.go

How to run

  1. Redis is running
  2. envoyds [<optional-config-path>]

API example usages

curl -X POST "http://localhost:8000/v1/registration/test?ip=123.124.125.126&service_repo_name=v&port=100&revision=44&tags={"az":"c"}"

curl -X GET "http://localhost:8000/v1/registration/test"

curl -X DELETE "http://localhost:8000/v1/registration/test/123.124.125.126"

curl -X DELETE "http://localhost:8000/v1/registration/test/123.124.125.126/100"

curl -X POST "http://localhost:8000/v1/loadbalancing/test/123.124.125.126/100?load_balancing_weight=3"

Improvements to original lyft/discovery

  1. It allows unique ip/port registration/removal issues/22
  2. Second index querying is done by querying indexes instead of whole list scan query_secondary_index

Integration tests

  1. cd envoyds
  2. go test envoyds_test.go

Reference

https://github.com/lyft/discovery

https://github.com/lyft/envoy

https://lyft.github.io/envoy/docs/intro/arch_overview/service_discovery.html

Documentation

Overview

Package envoyds is a generated protocol buffer package.

It is generated from these files:

pmessage.proto

It has these top-level messages:

ServiceGetResponse
ServicePostRequest
ServiceUpdateLoadBalancingRequest
Host
Tags

Index

Constants

View Source
const (
	CONTEXT_PARAMS        = "CONTEXT_PARAMS"
	CONTEXT_SERVICE       = "CONTEXT_SERVICE"
	CONTEXT_MARSHALER     = "CONTEXT_MARSHALER"
	PATH_VARIABLE_SERVICE = "service"
	PATH_VARIABLE_IP      = "ip_address"
	PATH_VARIABLE_PORT    = "port"
	HOST_TTL              = time.Minute * 10
)
View Source
const (
	REDIS_V1_PREFIX    = "EYV1"
	REDIS_SERVICE_NAME = "SERVICENAME"
	REDIS_REPO_NAME    = "REPONAME"
	REDIS_FIELD        = "META"
	REDIS_DELIMITER    = ":"
	REDIS_BATCH_SIZE   = 10
)
View Source
const CLIENT_PERIOD = time.Second * 20

Variables

This section is empty.

Functions

func NewEnvoyDS

func NewEnvoyDS(env string, redisHost string, redisPort int) (*service, error)

func NewRouter

func NewRouter(env, redisHost string, redisPort int) (*regexpRouter, error)

func ReadConfig

func ReadConfig(configPath string) *config

Types

type DsClient

type DsClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(dsIp string, dsPort int, ownIp string, ownPort int, service string) *DsClient

func (*DsClient) Register

func (c *DsClient) Register()

func (*DsClient) Start

func (c *DsClient) Start()

func (*DsClient) Stop

func (c *DsClient) Stop()

type Host

type Host struct {
	IpAddress       string `protobuf:"bytes,1,opt,name=ip_address,json=ipAddress" json:"ip_address,omitempty"`
	LastCheckIn     string `protobuf:"bytes,2,opt,name=last_check_in,json=lastCheckIn" json:"last_check_in,omitempty"`
	Port            int32  `protobuf:"varint,3,opt,name=port" json:"port,omitempty"`
	Revision        string `protobuf:"bytes,4,opt,name=revision" json:"revision,omitempty"`
	Service         string `protobuf:"bytes,5,opt,name=service" json:"service,omitempty"`
	ServiceRepoName string `protobuf:"bytes,6,opt,name=service_repo_name,json=serviceRepoName" json:"service_repo_name,omitempty"`
	Tags            *Tags  `protobuf:"bytes,7,opt,name=tags" json:"tags,omitempty"`
}

func (*Host) Descriptor

func (*Host) Descriptor() ([]byte, []int)

func (*Host) GetIpAddress

func (m *Host) GetIpAddress() string

func (*Host) GetLastCheckIn

func (m *Host) GetLastCheckIn() string

func (*Host) GetPort

func (m *Host) GetPort() int32

func (*Host) GetRevision

func (m *Host) GetRevision() string

func (*Host) GetService

func (m *Host) GetService() string

func (*Host) GetServiceRepoName

func (m *Host) GetServiceRepoName() string

func (*Host) GetTags

func (m *Host) GetTags() *Tags

func (*Host) ProtoMessage

func (*Host) ProtoMessage()

func (*Host) Reset

func (m *Host) Reset()

func (*Host) String

func (m *Host) String() string

type ServiceGetResponse

type ServiceGetResponse struct {
	Env     string  `protobuf:"bytes,1,opt,name=env" json:"env,omitempty"`
	Hosts   []*Host `protobuf:"bytes,2,rep,name=hosts" json:"hosts,omitempty"`
	Service string  `protobuf:"bytes,3,opt,name=service" json:"service,omitempty"`
}

func (*ServiceGetResponse) Descriptor

func (*ServiceGetResponse) Descriptor() ([]byte, []int)

func (*ServiceGetResponse) GetEnv

func (m *ServiceGetResponse) GetEnv() string

func (*ServiceGetResponse) GetHosts

func (m *ServiceGetResponse) GetHosts() []*Host

func (*ServiceGetResponse) GetService

func (m *ServiceGetResponse) GetService() string

func (*ServiceGetResponse) ProtoMessage

func (*ServiceGetResponse) ProtoMessage()

func (*ServiceGetResponse) Reset

func (m *ServiceGetResponse) Reset()

func (*ServiceGetResponse) String

func (m *ServiceGetResponse) String() string

type ServicePostRequest

type ServicePostRequest struct {
	Ip              string `protobuf:"bytes,1,opt,name=ip" json:"ip,omitempty"`
	ServiceRepoName string `protobuf:"bytes,2,opt,name=service_repo_name,json=serviceRepoName" json:"service_repo_name,omitempty"`
	Port            int32  `protobuf:"varint,3,opt,name=port" json:"port,omitempty"`
	Revision        string `protobuf:"bytes,4,opt,name=revision" json:"revision,omitempty"`
	Tags            *Tags  `protobuf:"bytes,5,opt,name=tags" json:"tags,omitempty"`
}

func (*ServicePostRequest) Descriptor

func (*ServicePostRequest) Descriptor() ([]byte, []int)

func (*ServicePostRequest) FieldMap

func (r *ServicePostRequest) FieldMap(req *http.Request) binding.FieldMap

func (*ServicePostRequest) GetIp

func (m *ServicePostRequest) GetIp() string

func (*ServicePostRequest) GetPort

func (m *ServicePostRequest) GetPort() int32

func (*ServicePostRequest) GetRevision

func (m *ServicePostRequest) GetRevision() string

func (*ServicePostRequest) GetServiceRepoName

func (m *ServicePostRequest) GetServiceRepoName() string

func (*ServicePostRequest) GetTags

func (m *ServicePostRequest) GetTags() *Tags

func (*ServicePostRequest) ProtoMessage

func (*ServicePostRequest) ProtoMessage()

func (*ServicePostRequest) Reset

func (m *ServicePostRequest) Reset()

func (*ServicePostRequest) String

func (m *ServicePostRequest) String() string

type ServiceUpdateLoadBalancingRequest

type ServiceUpdateLoadBalancingRequest struct {
	LoadBalancingWeight int32 `protobuf:"varint,1,opt,name=load_balancing_weight,json=loadBalancingWeight" json:"load_balancing_weight,omitempty"`
}

func (*ServiceUpdateLoadBalancingRequest) Descriptor

func (*ServiceUpdateLoadBalancingRequest) Descriptor() ([]byte, []int)

func (*ServiceUpdateLoadBalancingRequest) FieldMap

func (*ServiceUpdateLoadBalancingRequest) GetLoadBalancingWeight

func (m *ServiceUpdateLoadBalancingRequest) GetLoadBalancingWeight() int32

func (*ServiceUpdateLoadBalancingRequest) ProtoMessage

func (*ServiceUpdateLoadBalancingRequest) ProtoMessage()

func (*ServiceUpdateLoadBalancingRequest) Reset

func (*ServiceUpdateLoadBalancingRequest) String

type Tags

type Tags struct {
	Az                  string `protobuf:"bytes,1,opt,name=az" json:"az,omitempty"`
	Region              string `protobuf:"bytes,2,opt,name=region" json:"region,omitempty"`
	InstanceId          string `protobuf:"bytes,3,opt,name=instance_id,json=instanceId" json:"instance_id,omitempty"`
	Canary              bool   `protobuf:"varint,4,opt,name=canary" json:"canary,omitempty"`
	LoadBalancingWeight int32  `protobuf:"varint,5,opt,name=load_balancing_weight,json=loadBalancingWeight" json:"load_balancing_weight,omitempty"`
}

func (*Tags) Descriptor

func (*Tags) Descriptor() ([]byte, []int)

func (*Tags) GetAz

func (m *Tags) GetAz() string

func (*Tags) GetCanary

func (m *Tags) GetCanary() bool

func (*Tags) GetInstanceId

func (m *Tags) GetInstanceId() string

func (*Tags) GetLoadBalancingWeight

func (m *Tags) GetLoadBalancingWeight() int32

func (*Tags) GetRegion

func (m *Tags) GetRegion() string

func (*Tags) ProtoMessage

func (*Tags) ProtoMessage()

func (*Tags) Reset

func (m *Tags) Reset()

func (*Tags) String

func (m *Tags) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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