gateway

package
v0.73.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

README

API Gateways

This package provides GraphQL & REST gateways. These are connected in to the core via GRPC.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxSubscriptionReached = func(ip string, max uint32) error {
	return fmt.Errorf("max subscriptions count (%v) reached for ip (%s)", max, ip)
}

Functions

func Chain added in v0.56.0

func Chain(f http.Handler, m ...func(http.Handler) http.Handler) http.Handler

Chain builds the middleware Chain recursively, functions are first class.

func GenerateTlsConfig added in v0.67.1

func GenerateTlsConfig(g *Config, vegaPaths paths.Paths) (*tls.Config, http.Handler, error)

func MetricCollectionMiddleware

func MetricCollectionMiddleware(next http.Handler) http.Handler

MetricCollectionMiddleware records the request and the time taken to service it.

func RemoteAddrMiddleware

func RemoteAddrMiddleware(log *logging.Logger, next http.Handler) http.Handler

RemoteAddrMiddleware is a middleware adding to the current request context the address of the caller.

func WithAddHeadersMiddleware added in v0.56.0

func WithAddHeadersMiddleware(next http.Handler) http.Handler

Types

type Config

type Config struct {
	ServerConfig
	Level                    encoding.LogLevel        `` /* 148-byte string literal not displayed */
	Timeout                  encoding.Duration        `long:"timeout"`
	Node                     ServerConfig             `group:"Node"                                                                    namespace:"node"`
	GraphQL                  GraphqlServiceConfig     `group:"GraphQL"                                                                 namespace:"graphql"`
	REST                     RESTGatewayServiceConfig `group:"REST"                                                                    namespace:"rest"`
	SubscriptionRetries      int                      `description:" "                                                                 long:"subscription-retries"`
	GraphQLPlaygroundEnabled encoding.Bool            `description:"Enables the GraphQL playground"                                    long:"graphql-playground"`
	MaxSubscriptionPerClient uint32                   `description:"Maximum graphql subscriptions allowed per client"                  long:"max-subscription-per-client"`
	CORS                     libhttp.CORSConfig       `group:"CORS"                                                                    namespace:"cors"`
	HTTPSEnabled             encoding.Bool            `description:"If true, GraphQL gateway will require an HTTPS connection"         long:"https-enabled"`
	AutoCertDomain           string                   `description:"Automatically generate and sign https certificate via LetsEncrypt" long:"auto-cert-domain"`
	CertificateFile          string                   `description:"Path to SSL certificate, if using HTTPS but not autocert"          long:"certificate-file"`
	KeyFile                  string                   `description:"Path to private key, if using HTTPS but not autocert"              long:"key-file"`
	RateLimit                ratelimit.Config         `group:"RateLimits"                                                              namespace:"rate-limits"`
}

Config represents the general configuration for the gateway.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type GraphqlServiceConfig

type GraphqlServiceConfig struct {
	Enabled         encoding.Bool `description:"Start the GraphQl gateway"             long:"enabled"`
	ComplexityLimit int           `long:"complexity-limit"`
	Endpoint        string        `description:"Endpoint to expose the graphql API at" long:"endpoint"`
}

GraphqlServiceConfig represents the configuration of the gateway.

type InjectableResponseWriter added in v0.56.0

type InjectableResponseWriter struct {
	http.ResponseWriter
	http.Hijacker
	// contains filtered or unexported fields
}

func InjectableWriterFromContext added in v0.56.0

func InjectableWriterFromContext(ctx context.Context) (*InjectableResponseWriter, bool)

func (*InjectableResponseWriter) SetHeaders added in v0.56.0

func (i *InjectableResponseWriter) SetHeaders(headers http.Header)

func (*InjectableResponseWriter) Write added in v0.56.0

func (i *InjectableResponseWriter) Write(data []byte) (int, error)

type RESTGatewayServiceConfig

type RESTGatewayServiceConfig struct {
	Enabled    encoding.Bool `choice:"true" choice:"false" description:"Start the REST gateway" long:"enabled"`
	APMEnabled encoding.Bool `choice:"true" choice:"false" description:" "                      long:"apm-enabled"`
}

RESTGatewayServiceConfig represent the configuration of the rest service.

type ServerConfig

type ServerConfig struct {
	Port int    `description:"Listen for connection on port <port>" long:"port"`
	IP   string `description:"Bind to address <ip>"                 long:"ip"`
}

ServerConfig represent the configuration of a server in vega.

type SubscriptionRateLimiter added in v0.57.0

type SubscriptionRateLimiter struct {
	MaxSubscriptions uint32
	// contains filtered or unexported fields
}

func NewSubscriptionRateLimiter added in v0.57.0

func NewSubscriptionRateLimiter(
	log *logging.Logger,
	maxSubscriptions uint32,
) *SubscriptionRateLimiter

func (*SubscriptionRateLimiter) Dec added in v0.57.0

func (s *SubscriptionRateLimiter) Dec(ip string)

func (*SubscriptionRateLimiter) Inc added in v0.57.0

func (*SubscriptionRateLimiter) WithGrpcInterceptor added in v0.70.0

func (s *SubscriptionRateLimiter) WithGrpcInterceptor(ipGetterFunc ipGetter) grpc.StreamServerInterceptor

func (*SubscriptionRateLimiter) WithSubscriptionRateLimiter added in v0.57.0

func (s *SubscriptionRateLimiter) WithSubscriptionRateLimiter(next http.Handler) http.Handler

Directories

Path Synopsis
Package gql contains code for running the GraphQL-to-gRPC gateway.
Package gql contains code for running the GraphQL-to-gRPC gateway.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package rest contains code for running the REST-to-gRPC gateway.
Package rest contains code for running the REST-to-gRPC gateway.

Jump to

Keyboard shortcuts

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