microservices

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitialConnectionTimeout time.Duration = 30 * time.Second
)

Variables

View Source
var CORS_ALLOWED_HEADERS = []string{"Authorization", "Content-Type"}
View Source
var CORS_ALLOWED_METHODS_ALL = [...]string{"GET", "POST", "PUT", "HEAD", "OPTIONS", "DELETE"}
View Source
var CORS_ALLOWED_ORIGINS = []string{"*"}
View Source
var CORS_HANDLER_ALLOWED_HEADERS = handlers.AllowedHeaders(CORS_ALLOWED_HEADERS)
View Source
var CORS_HANDLER_ALLOWED_METHODS = handlers.AllowedMethods(CORS_ALLOWED_METHODS_ALL[:])
View Source
var CORS_HANDLER_ALLOWED_ORIGINS = handlers.AllowedOrigins(CORS_ALLOWED_ORIGINS)

Functions

func BuildClusterConfig

func BuildClusterConfig(serviceConfig *ServiceConfig) (*rest.Config, *hfClientset.Clientset)

func BuildTLSClientCredentials

func BuildTLSClientCredentials(caPath string) (credentials.TransportCredentials, error)

func ConnectionWatchdog

func ConnectionWatchdog(svc MicroService, conn *grpc.ClientConn)

Watchdog for grpc Connection that logs state changes Only log changes if - moving to TransientFailure or Shutdown - moving to any other state when there was an Error (this happens until the error is resolved and the state = READY)

Second watchdog tries to catch initial connection errors

func CreateGRPCServer

func CreateGRPCServer(c credentials.TransportCredentials) *grpc.Server

/ Used to create new gcpr server with options

func EstablishConnection

func EstablishConnection(svc MicroService, cert credentials.TransportCredentials) *grpc.ClientConn

/ Used to create new gcpr client with options

func EstablishConnections

func EstablishConnections(services []MicroService, cert credentials.TransportCredentials) map[MicroService]*grpc.ClientConn

func StartAPIServer

func StartAPIServer(server APIServer)

Common method that starts a microservices API server

func StartGRPCServer

func StartGRPCServer(server *grpc.Server, enableReflection bool)

Common method that starts a microservices grpc server

Types

type APIServer

type APIServer interface {
	SetupRoutes(r *mux.Router)
}

Interface for http APIServers that share the common method "SetupRoutes".

type MicroService

type MicroService string

Add type MicroService based on string that is used to define constants for every service

const (
	AuthN      MicroService = "authn-service"
	AuthR      MicroService = "authr-service"
	User       MicroService = "user-service"
	Rbac       MicroService = "rbac-service"
	AccessCode MicroService = "accesscode-service"
	Setting    MicroService = "setting-service"
)

type ServiceConfig

type ServiceConfig struct {
	TLSCert          string
	TLSKey           string
	TLSCA            string
	WebhookTLSCA     string
	LocalMasterUrl   string
	LocalKubeconfig  string
	EnableReflection bool
	ClientCert       credentials.TransportCredentials
	ServerCert       credentials.TransportCredentials
}

ServiceConfig holds the configuration for a service

func BuildServiceConfig

func BuildServiceConfig() *ServiceConfig

ParseFlags declares the flags and parses them, then returns a ServiceConfig struct.

Jump to

Keyboard shortcuts

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