stela

package module
v0.0.0-...-00593c4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

README

Stela

A microservice used for discovery of services with gRPC. Stela uses IPv6 multicast to allow for scalable, distributed discovery on premises. The project is named after the stone monuments of the same name.

Features
  • Distributed run one or many Stela instances on any number of computers.
  • Subscriptions subscribe to service names to receive a stream of any services registered or deregistered with that name.
  • Simple Stela is meant to be started quickly with little configuration. It only focuses on service registration.

Installation

Go
  • go get -u github.com/forestgiant/stela/...

Running stela nodes

By default communicates over gRPC :3100 and IPv6 multicast :31053. Start your first instance:

stela -cert /path/to/server.crt -key /path/to/server.key -ca /path/to/ca.crt

If the SSL files you wish to use are stored as server.crt, server.key, and ca.crt in the directory where the command is issued, you can omit the cert, key, and ca parameters. Alternatively you can use the -insecure flag if you don't want to use SSL/TLS gRPC.

stela

Start two other instances on the same computer.

$ stela -port 31001

$ stela -port 31002

Or start another instances on a different computer.

$ stela

Services registered with any of the instances will be discoverable by all.

Examples

  • stela watchdog: cmd/stelawd/
  • Membership: examples/membership/
  • API Example: Refer to api/example_test.go

Usage

  -ca string
    	Path to the private key file for the server. (default "ca.crt")
  -cert string
    	Path to the certificate file for the server. (default "server.crt")
  -insecure
    	Disable SSL, allowing unenecrypted communication with this service.
  -key string
    	Path to the private key file for the server. (default "server.key")
  -multicast int
    	Port used to multicast to other stela members. (default 31053)
  -port int
    	Port for stela's gRPC API. (default 31000)
  -serverName string
    	The common name of the server you are connecting to. (default "Stela")
  -status
    	Shows how many stela instances are currently running. *Only works if you are running a local stela instance.
  -version
    	Prints current version

Documentation

Index

Constants

View Source
const (
	// Version of stela
	Version = "0.11.6"

	// DefaultStelaAddress by default stela assumes there is a local instance running
	DefaultStelaAddress = "127.0.0.1:31000"

	// DefaultStelaPort by default stela assumes there is a local instance running
	DefaultStelaPort = 31000

	// DefaultMulticastAddress is the multicast IPV6 address stela communicates on
	DefaultMulticastAddress = "[ff12::9000]"

	// DefaultMulticastPort is the default multicast port
	DefaultMulticastPort = 31053

	// ServiceName is how stela instances are registered as services
	ServiceName = "stela.services.fg"

	// DefaultMaxValueBytes only allows the Value byte slice to be 256 bytes
	DefaultMaxValueBytes = 256

	// DefaultServerName Used for TLS gRPC. Name that matches the common name in the certificate of the server
	DefaultServerName = "Stela"
)
View Source
const (
	RegisterAction   = iota
	DeregisterAction = iota
)

Actions for Service

Variables

This section is empty.

Functions

func DecodeValue

func DecodeValue(b []byte) interface{}

DecodeValue converts byte slice to interface{}

func EncodeValue

func EncodeValue(v interface{}) []byte

EncodeValue converts interface{} to a byte slice

Types

type Client

type Client struct {
	Address string // IPv4 address
	ID      string
	// contains filtered or unexported fields
}

Client struct holds all the information about a client registering a service

func (*Client) Equal

func (c *Client) Equal(testClient *Client) bool

Equal tests if a Service is the same

func (*Client) GenerateID

func (c *Client) GenerateID() error

GenerateID will overwrite the id with a new rand 10 byte string

func (*Client) Notify

func (c *Client) Notify(s *Service)

Notify sends a service to the client's subscribeCh

func (*Client) SubscribeCh

func (c *Client) SubscribeCh() <-chan *Service

SubscribeCh returns a channel of Services that is sent a service when one is removed or added

type Service

type Service struct {
	Name     string
	Hostname string
	IPv4     string
	IPv6     string
	Port     int32
	Priority int32
	Timeout  int32 // The length of time, in milliseconds, before a service is deregistered
	Action   int32
	Client   *Client // Store reference to the client that registered the service
	Value    []byte
	// contains filtered or unexported fields
}

Service used in request/response

func (Service) Equal

func (s Service) Equal(testService *Service) bool

Equal tests if a Service is the same

func (*Service) GenerateID

func (s *Service) GenerateID() error

GenerateID will overwrite the id with a new rand 10 byte string

func (*Service) ID

func (s *Service) ID() string

ID getter return s.id

func (*Service) IPv4Address

func (s *Service) IPv4Address() string

IPv4Address helper to combine IPv4 and Port

func (*Service) IPv6Address

func (s *Service) IPv6Address() string

IPv6Address helper to combine IPv4 and Port

func (Service) String

func (s Service) String() string

Stringer

func (*Service) Valid

func (s *Service) Valid() bool

Valid test the required fields of a Service

Directories

Path Synopsis
cmd
examples
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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