microservices

package
v3.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 25 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, *kubernetes.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 GetWorkerThreadCount added in v3.2.0

func GetWorkerThreadCount() int

This method tries to retreive the controller thread count from an environment variable CONTROLLER_THREAD_COUNT otherwise it sets the thread count to the default value

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 (
	AccessCode     MicroService = "accesscode-service"
	AuthN          MicroService = "authn-service"
	AuthR          MicroService = "authr-service"
	Course         MicroService = "course-service"
	DBConfig       MicroService = "dbconfig-service"
	Environment    MicroService = "environment-service"
	Progress       MicroService = "progress-service"
	Rbac           MicroService = "rbac-service"
	Scenario       MicroService = "scenario-service"
	ScheduledEvent MicroService = "scheduledevent-service"
	Session        MicroService = "session-service"
	Setting        MicroService = "setting-service"
	Terraform      MicroService = "terraform-service"
	User           MicroService = "user-service"
	VMClaim        MicroService = "vmclaim-service"
	VMSet          MicroService = "vmset-service"
	VM             MicroService = "vm-service"
	VMTemplate     MicroService = "vmtemplate-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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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