radiant

package module
v0.0.0-...-55171a9 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 7 Imported by: 1

README

Radiant

Photo by Jakub Novacek on Pexels

Radiant

Radiant is a GRPC proxy service using Caddy.

Radiant uses a datastore to store server info. By default, there is a simple in-memory datastore. You can implement whatever you want to integrate with external systems.

Building

Uses dep for dependencies.

  • make

To just build binaries:

  • make binaries

Usage

To start the server, run:

$> radiant

Or via code:

// create config
cfg := &radiant.Config{
	GRPCAddr:  "unix:///run/radiant.sock",
	HTTPPort:  80,
	HTTPSPort: 443,
	Debug:     true,
}
// instantiate a datastore
memDs := memory.NewMemory()

// create the server
srv, _ := server.NewServer(cfg, memDs)

// run the server
_ = srv.Run()

This will start both the proxy and GRPC servers.

There is a Go client available to assist in usage:

client, _ := radiant.NewClient("unix:///run/radiant.sock")

timeout := time.Second * 30
upstreams := []string{
    "http://1.2.3.4",
    "http://5.6.7.8",
}
opts := []radiant.AddOpts{
    radiant.WithUpstreams(upstreams...),
    radiant.WithTimeouts(timeout),
    radiant.WithTLS,
}

// add the server
_ = client.AddServer(host, opts...)

// reload the proxy to take effect
_ = client.Reload()

// remove the server
_ = client.RemoveServer(host)

// reload to take effect
_ = client.Reload()

It is safe to reload as often as you wish. There is zero downtime for the reload operation.

There is also a CLI that can be used directly or as reference.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTLS

func WithTLS(ctx context.Context, srv *api.Server) error

Types

type AddOpts

type AddOpts func(ctx context.Context, srv *api.Server) error

func WithPath

func WithPath(path string) AddOpts

func WithPolicy

func WithPolicy(p api.Policy) AddOpts

func WithPreset

func WithPreset(preset string) AddOpts

func WithServer

func WithServer(s *api.Server) AddOpts

func WithTimeouts

func WithTimeouts(d time.Duration) AddOpts

func WithUpstreams

func WithUpstreams(upstreams ...string) AddOpts

type Client

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

func NewClient

func NewClient(addr string) (*Client, error)

func (*Client) AddServer

func (c *Client) AddServer(host string, opts ...AddOpts) error

func (*Client) Close

func (c *Client) Close()

func (*Client) Config

func (c *Client) Config() ([]byte, error)

func (*Client) Reload

func (c *Client) Reload() error

func (*Client) RemoveServer

func (c *Client) RemoveServer(host string) error

func (*Client) Servers

func (c *Client) Servers() ([]*api.Server, error)

type Config

type Config struct {
	GRPCAddr     string
	DatastoreUri string
	HTTPPort     int
	HTTPSPort    int
	TLSEmail     string
	Debug        bool
}

Directories

Path Synopsis
api
v1
cmd
ds

Jump to

Keyboard shortcuts

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