gate

package
v0.0.0-...-90dec0a Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: GPL-3.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gate

The gate is an API Gateway.

Supported Protocols

  • HTTP
  • WebSocket

Features

  • Translate HTTP round-trip to RPC to backend micro-services.
  • Translate WebSocket to bidirectional streaming RPC to backend services.
  • JSON payload is sent to and recv from backend services as it is.
  • Backend services are discovered by service name and selected evenly across multiple instances.
  • HTTP paths are dynamically mapped to services by the resolver as below.

Resolver

gate dynamically routes to services using a namespace value and the HTTP path. If a service have a name (io.goeasy.service.comet) and a method (Comet.Subscribe), let's first define some concepts:

io.goeasy.service.comet/Comet.Subscribe
<---1---> <--2--> <-3-> <------5------>
<----------4---------->
  • Part 1 is a namespace
  • Part 2 is a type
  • Part 3 is an alias, or short name
  • Altogether they compose part 4, which is FQDN, the global unique service name
  • Part 5 is a method or endpoint

URLs are resolved as follows:

Path Service Method
/foo/bar io.goeasy.service.foo Foo.Bar
/foo/bar/baz io.goeasy.service.foo Bar.Baz
/foo/bar/baz/cat io.goeasy.service.foo.bar Baz.Cat

Versioned API URLs can easily be mapped to service names:

Path Service Method
/foo/bar io.goeasy.service.foo Foo.Bar
/v1/foo/bar io.goeasy.service.v1.foo Foo.Bar
/v1/foo/bar/baz io.goeasy.service.v1.foo Bar.Baz
/v2/foo/bar io.goeasy.service.v2.foo Foo.Bar
/v2/foo/bar/baz io.goeasy.service.v2.foo Bar.Baz

Documentation

Index

Constants

View Source
const (
	ServiceName = "gate"
	APIPath     = "/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Address   string `json:"api_serving_address"`
	Namespace string `json:"namespace"`
}

func NewServer

func NewServer() *Server

func (*Server) Name

func (s *Server) Name() string

func (*Server) Run

func (s *Server) Run()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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