sonic

package module
v0.0.0-...-9823ec8 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: Apache-2.0 Imports: 56 Imported by: 0

README

Sonic API Gateway

Sonic API Gateway

Build Go Report Card GoDoc

Sonic is an API Gateway that aggregates and manipulates multiple data sources coming from your microservices to provide the exact API your end-user products need while offering awesome performance.

Installation

Sonic is a single binary file that does not require any external libraries to work. To install Sonic choose your operative system in the downloads section or use the Docker image.

Generate your sonic.json here or use the sample file (updating...)

Docker

If you are already familiar with Docker, the easiest way to get started is by pulling and running the Sonic image from the Docker Hub.

Share your configuration as a volume (mapped to /etc/sonic). Inside the volume you need at least the sonic.json file which contains the endpoint definition of you application.

Pull the image and run Sonic (default parameters):

docker pull starvn/sonic:tagname
docker run -p 8080:8080 -v $PWD:/etc/sonic/ starvn/sonic:tagname

Run with the debug enabled (flag -d):

docker run -p 8080:8080 -v "${PWD}:/etc/sonic/" starvn/sonic:tagname run -d -c /etc/sonic/sonic.json

When the container is running with the previous line you can access the health endpoint:

curl HTTP://localhost:8080/__health

Check the syntax of the configuration file:

docker run -it -p 8080:8080 -v $PWD:/etc/sonic/ starvn/sonic:tagname check --config sonic.json

Show the help:

docker run -it -p 8080:8080 -v $PWD:/etc/sonic/ starvn/sonic:tagname --help

Development setup

You need Golang >= 1.17

Note: if you are using windows, we recommend you to build the project on linux

Fork the sonic project

Go to the sonic project and click on the "fork" button. You can then clone your own fork of the project, and start working on it.

Please read the Github forking documentation for more information.

Build
make build
Build with docker
make build_on_docker

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadPlugins

func LoadPlugins(folder, pattern string, logger log.Logger)

func NewBackendFactory

func NewBackendFactory(logger log.Logger, metricCollector *metrics.Metrics) proxy.BackendFactory

func NewBackendFactoryWithContext

func NewBackendFactoryWithContext(ctx context.Context, logger log.Logger, metricCollector *metrics.Metrics) proxy.BackendFactory

func NewEngine

func NewEngine(cfg config.ServiceConfig, logger log.Logger, w io.Writer) *gin.Engine

func NewExecutor

func NewExecutor(ctx context.Context) cmd.Executor

func NewHandlerFactory

func NewHandlerFactory(logger log.Logger, metricCollector *metrics.Metrics, rejecter jose.RejecterFactory) router.HandlerFactory

func NewProxyFactory

func NewProxyFactory(logger log.Logger, backendFactory proxy.BackendFactory, metricCollector *metrics.Metrics) proxy.Factory

func RegisterEncoders

func RegisterEncoders()

func RegisterSubscriberFactories

func RegisterSubscriberFactories(ctx context.Context, cfg config.ServiceConfig, logger log.Logger) func(n string, p int)

Types

type BackendFactory

type BackendFactory interface {
	NewBackendFactory(context.Context, log.Logger, *metrics.Metrics) proxy.BackendFactory
}

type BloomFilterJWT

type BloomFilterJWT struct{}

func (BloomFilterJWT) NewTokenRejecter

func (t BloomFilterJWT) NewTokenRejecter(ctx context.Context, cfg config.ServiceConfig, l log.Logger, reg func(n string, p int)) (jose.ChainedRejecterFactory, error)

type DefaultRunServerFactory

type DefaultRunServerFactory struct{}

func (*DefaultRunServerFactory) NewRunServer

type EngineFactory

type EngineFactory interface {
	NewEngine(config.ServiceConfig, log.Logger, io.Writer) *gin.Engine
}

type ExecutorBuilder

type ExecutorBuilder struct {
	LoggerFactory               LoggerFactory
	PluginLoader                PluginLoader
	SubscriberFactoriesRegister SubscriberFactoriesRegister
	TokenRejecterFactory        TokenRejecterFactory
	MetricsAndTracesRegister    MetricsAndTracesRegister
	EngineFactory               EngineFactory
	ProxyFactory                ProxyFactory
	BackendFactory              BackendFactory
	HandlerFactory              HandlerFactory
	RunServerFactory            RunServerFactory

	Middlewares []gin.HandlerFunc
}

func (*ExecutorBuilder) NewCmdExecutor

func (e *ExecutorBuilder) NewCmdExecutor(ctx context.Context) cmd.Executor

type HandlerFactory

type HandlerFactory interface {
	NewHandlerFactory(log.Logger, *metrics.Metrics, jose.RejecterFactory) router.HandlerFactory
}

type LoggerBuilder

type LoggerBuilder struct{}

func (LoggerBuilder) NewLogger

type LoggerFactory

type LoggerFactory interface {
	NewLogger(config.ServiceConfig) (log.Logger, io.Writer, error)
}

type MetricsAndTraces

type MetricsAndTraces struct{}

func (MetricsAndTraces) Register

type MetricsAndTracesRegister

type MetricsAndTracesRegister interface {
	Register(context.Context, config.ServiceConfig, log.Logger) *metrics.Metrics
}

type PluginLoader

type PluginLoader interface {
	Load(folder, pattern string, logger log.Logger)
}

type ProxyFactory

type ProxyFactory interface {
	NewProxyFactory(log.Logger, proxy.BackendFactory, *metrics.Metrics) proxy.Factory
}

type RunServerFactory

type RunServerFactory interface {
	NewRunServer(log.Logger, router.RunServerFunc) RunServer
}

type SubscriberFactoriesRegister

type SubscriberFactoriesRegister interface {
	Register(context.Context, config.ServiceConfig, log.Logger) func(string, int)
}

type TokenRejecterFactory

type TokenRejecterFactory interface {
	NewTokenRejecter(context.Context, config.ServiceConfig, log.Logger, func(string, int)) (jose.ChainedRejecterFactory, error)
}

Directories

Path Synopsis
auth
jose
Package jose provides Javascript Object Signing and Encryption
Package jose provides Javascript Object Signing and Encryption
oauth
Package oauth add support for auth2 client credentials grant to the Sonic API Gateway
Package oauth add support for auth2 client credentials grant to the Sonic API Gateway
backend
lambda
Package lambda provides lambda functions for the Sonic API Gateway
Package lambda provides lambda functions for the Sonic API Gateway
pubsub
Package pubsub provides a pubsub backend for the Sonic
Package pubsub provides a pubsub backend for the Sonic
queue
Package queue provides an AMQP compatible backend for the Sonic API Gateway
Package queue provides an AMQP compatible backend for the Sonic API Gateway
cmd
gateway
Sonic sets up a complete Sonic API Gateway ready to serve
Sonic sets up a complete Sonic API Gateway ready to serve
modifier
interpreter
Package interpreter provides a lua interpreter for the Sonic API Gateway
Package interpreter provides a lua interpreter for the Sonic API Gateway
qos
circuitbreaker/eapache
Package eapache provides a circuit breaker adapter using the github.com/eapache/go-resiliency/breaker lib
Package eapache provides a circuit breaker adapter using the github.com/eapache/go-resiliency/breaker lib
circuitbreaker/gobreaker
Package gobreaker provides a circuit circuitbreaker adapter using the sony/gobreaker lib.
Package gobreaker provides a circuit circuitbreaker adapter using the sony/gobreaker lib.
httpcache
Package httpcache introduces an in-memory-cached http client into the Sonic stack
Package httpcache introduces an in-memory-cached http client into the Sonic stack
ratelimit
Package ratelimit contains a collection of curated rate limit adaptors for the Sonic API Gateway
Package ratelimit contains a collection of curated rate limit adaptors for the Sonic API Gateway
ratelimit/juju
Package juju provides a set of rate-limit proxy and router middlewares using the github.com/juju/ratelimit lib
Package juju provides a set of rate-limit proxy and router middlewares using the github.com/juju/ratelimit lib
ratelimit/juju/proxy
Package proxy provides a rate-limit proxy middleware using the github.com/juju/ratelimit lib
Package proxy provides a rate-limit proxy middleware using the github.com/juju/ratelimit lib
ratelimit/juju/router
Package router provides several rate-limit routers using the github.com/juju/ratelimit lib.
Package router provides several rate-limit routers using the github.com/juju/ratelimit lib.
ratelimit/rate
Package rate provides a set of rate-limit proxy and router middlewares using the golang.org/x/time/rate lib
Package rate provides a set of rate-limit proxy and router middlewares using the golang.org/x/time/rate lib
ratelimit/rate/router
Package router provides several rate-limit routers using the golang.org/x/time/rate lib
Package router provides several rate-limit routers using the golang.org/x/time/rate lib
security
cors
Package cors provides CORS support
Package cors provides CORS support
detector
Package detector provides a bot detector middleware for the Sonic API Gateway
Package detector provides a bot detector middleware for the Sonic API Gateway
httpsecure
Package httpsecure provides a complete http security layer for the Sonic API Gateway
Package httpsecure provides a complete http security layer for the Sonic API Gateway
support
cobra
Package cobra defines the cobra command structs and an execution method for adding an improved CLI to Sonic based API Gateways
Package cobra defines the cobra command structs and an execution method for adding an improved CLI to Sonic based API Gateways
conflex
Package conflex provides extended features for Sonic config parsers
Package conflex provides extended features for Sonic config parsers
encoding/rss
Package rss provides RSS encoding support
Package rss provides RSS encoding support
encoding/xml
Package xml provides XML encoding support
Package xml provides XML encoding support
viper
Package viper defines a config parser implementation based on the viper pkg
Package viper defines a config parser implementation based on the viper pkg
telemetry
gelf
Package gelf just return a gelf writer with the configuration provided via Sonic ExtraConfig
Package gelf just return a gelf writer with the configuration provided via Sonic ExtraConfig
gologging
Package gologging provides a logger implementation based on the github.com/op/go-log pkg
Package gologging provides a logger implementation based on the github.com/op/go-log pkg
influxdb
Package influxdb provides metric collector for Sonic
Package influxdb provides metric collector for Sonic
logstash
Package logstash provides a logstash formatter for the sonic-gologging pkg
Package logstash provides a logstash formatter for the sonic-gologging pkg
metrics
Package metrics defines a set of basic building blocks for instrumenting Sonic gateways
Package metrics defines a set of basic building blocks for instrumenting Sonic gateways
metrics/gin
Package gin defines a set of basic building blocks for instrumenting Sonic gateways built using the gin router
Package gin defines a set of basic building blocks for instrumenting Sonic gateways built using the gin router
metrics/mux
Package mux defines a set of basic building blocks for instrumenting Sonic gateways built using the mux router
Package mux defines a set of basic building blocks for instrumenting Sonic gateways built using the mux router
Package test implements utility functions to help with API Gateway testing
Package test implements utility functions to help with API Gateway testing
validation
explang
Package explang provides a Common Expression Language (EXPLANG) module for the Sonic API Gateway
Package explang provides a Common Expression Language (EXPLANG) module for the Sonic API Gateway
jsonschema
Package jsonschema provides a JSONschema jsonschema for the Sonic API Gateway
Package jsonschema provides a JSONschema jsonschema for the Sonic API Gateway

Jump to

Keyboard shortcuts

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