server

package
v0.0.0-...-cda7898 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package server is the api-gateway server, handling all its requests with a HTTP server. Call NewServer to get a new server.Server instance, and Use Server.Listen to listen and serve the server on a port. Configuration is done using environment variables: GW_PORT: Port on which the server would listen.

default: 8080

GW_AUTH_URL: The url of the authentication service to redirect the user to authenticate.

default: "http://localhost/auth/login"

GW_DOCS_URL: The url of the edit docs.

default: "http://localhost/3000/api/files"

GW_SECRET: The secret used to validate authorization jwt tokens.

default: "pandora@drive"

GW_UPLOAD_SERVICE: The address of the upload-service.

default: "upload-service:8080"

GW_DOWNLOAD_SERVICE: The address of the download-service.

default: "download-service:8080"

GW_FILE_SERVICE: The address of the file-service.

default: "file-service:8080"

GW_EXTERNAL_APM_URL: External server's client APM url.

default: "http://localhost:8200"

GW_ALLOW_ORIGINS: List of allowed origins for the Access-Control-Allow-Origin header.

default: "http://localhost*", can be a list of urls.

For configuring the APM agent see https://www.elastic.co/guide/en/apm/agent/go/current/configuration.html For configuring the logger of the server see Package logger doc.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetricsLogger

func NewMetricsLogger() gin.HandlerFunc

NewMetricsLogger initializes the metrics middleware.

func NewRouter

func NewRouter(logger *logrus.Logger) (*gin.Engine, []*grpcPoolTypes.ConnPool)

NewRouter creates new gin.Engine for the api-gateway server and sets it up.

Types

type ExternalNetworkDest

type ExternalNetworkDest struct {
	Label          string `json:"label"`
	Value          string `json:"value"`
	AppID          string `json:"appID"`
	ApprovalURL    string `json:"approvalUrl"`
	ApprovalUIURL  string `json:"approvalUIUrl"`
	IsDefault      bool   `json:"isDefault"`
	IsEnabled      bool   `json:"isEnabled"`
	IsOnlyApprover bool   `json:"isOnlyApprover"`
}

ExternalNetworkDest configuration of external network

func GetExternalNetworksConfiguration

func GetExternalNetworksConfiguration() []ExternalNetworkDest

GetExternalNetworksConfiguration get network object configuration

type Health

type Health int32

Health is an atomic Boolean Its methods are all atomic, thus safe to be called by multiple goroutines simultaneously Note: When embedding into a struct, one should always use *Health to avoid copy

func NewHealthChecker

func NewHealthChecker() *Health

NewHealthChecker creates a new Health with default to false

func (*Health) Check

func (h *Health) Check(
	interval int,
	rpcTimeout int,
	logger *logrus.Logger,
	gotenberg *gotenberg.Client,
	badConns chan<- *grpcPoolTypes.ConnPool,
	nonFatalConns []*grpcPoolTypes.ConnPool,
	fatalConns ...*grpcPoolTypes.ConnPool)

Check checks healthiness of conns once in interval seconds.

func (*Health) Get

func (h *Health) Get() bool

Get returns whether the Boolean is true

func (*Health) SetHealthy

func (h *Health) SetHealthy()

SetHealthy sets the Boolean to true

func (*Health) SetTo

func (h *Health) SetTo(yes bool)

SetTo sets the boolean with given Boolean

func (*Health) SetToIf

func (h *Health) SetToIf(old, new bool) (set bool)

SetToIf sets the Boolean to new only if the Boolean matches the old Returns whether the set was done

func (*Health) SetUnhealthy

func (h *Health) SetUnhealthy()

SetUnhealthy sets the Boolean to false

type Server

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

Server is a structure that holds the http server of the api-gateway.

func NewServer

func NewServer() *Server

NewServer creates a Server of the api-gateway.

func (*Server) Listen

func (s *Server) Listen()

Listen listens on configPort. Listen returns when listener is closed. Listener will be closed when this method returns, if listener is closed with non-nil error then it will be logged as fatal.

Directories

Path Synopsis
Package auth is used to handle authorization using a gin.HandlerFunc defined by Middleware.
Package auth is used to handle authorization using a gin.HandlerFunc defined by Middleware.

Jump to

Keyboard shortcuts

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