servicediscovery

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SERVICES_COLLECTION           = "services"
	SERVICE_GROUP_COLLECTION      = "services_groups"
	SERVICE_APPS_GROUP_COLLECTION = "services_apps_groups"
)

Variables

View Source
var Methods = map[string]map[string]interface{}{
	"mongo": {
		"delete":    DeleteServiceMongo,
		"update":    UpdateMongo,
		"create":    CreateServiceMongo,
		"list":      ListServicesMongo,
		"get":       FindMongo,
		"normalize": NormalizeServicesMongo},
	"file": {
		"delete":    DeleteServiceFile,
		"update":    UpdateFile,
		"create":    CreateServiceFile,
		"list":      ListServicesFile,
		"get":       FindFile,
		"normalize": NormalizeServicesFile}}
View Source
var PAGE_LENGTH = 10
View Source
var SD_TYPE = "file"
View Source
var SERVICE_NAME = "/service-discovery"

Functions

func Contains

func Contains(array []int, value int) bool

func CreateServiceFile

func CreateServiceFile(s Service) (string, int)

func CreateServiceMongo

func CreateServiceMongo(s Service) (string, int)

func DeleteServiceFile

func DeleteServiceFile(service Service) (string, int)

func DeleteServiceMongo

func DeleteServiceMongo(s Service) (string, int)

func GetMatchURI

func GetMatchURI(uri string) string

func GetMatchingURIRegex

func GetMatchingURIRegex(uri string) string

func InitServiceDiscovery

func InitServiceDiscovery()

func ListAllAvailableHosts

func ListAllAvailableHosts() ([]string, error)

func NormalizeServicesFile

func NormalizeServicesFile() error

func NormalizeServicesMongo

func NormalizeServicesMongo() error

func UpdateFile

func UpdateFile(service Service, serviceExists Service) (string, int)

func UpdateMongo

func UpdateMongo(service Service, serviceExists Service) (string, int)

func ValidateURL

func ValidateURL(url string) bool

Types

type ApplicationGroup

type ApplicationGroup struct {
	Id       bson.ObjectId `bson:"_id" json:"Id"`
	Name     string
	Services []bson.ObjectId
}

type Service

type Service struct {
	Id                         bson.ObjectId `bson:"_id" json:"Id"`
	Name                       string
	Hosts                      []string
	Domain                     string
	Port                       string
	MatchingURI                string
	MatchingURIRegex           string
	ToURI                      string
	Protected                  bool
	APIDocumentation           string
	IsCachingActive            bool
	IsActive                   bool
	HealthcheckUrl             string
	LastActiveTime             int64
	ServiceManagementHost      string
	ServiceManagementPort      string
	ServiceManagementEndpoints map[string]string
	RateLimit                  int
	RateLimitExpirationTime    int64
	IsReachable                bool
	GroupId                    bson.ObjectId `bson:"groupid,omitempty" json:"GroupId"`
	GroupVisibility            bool
	UseGroupAttributes         bool
	ProtectedExclude           map[string]string
}

func FindFile

func FindFile(service Service) (Service, error)

func FindMongo

func FindMongo(s Service) (Service, error)

func ListServicesFile

func ListServicesFile(page int, filterQuery string) []Service

func ListServicesMongo

func ListServicesMongo(page int, filterQuery string, viewAllPermission bool) []Service

func ValidateServiceBody

func ValidateServiceBody(c *routing.Context) (Service, error)

func ValidateServiceExists

func ValidateServiceExists(s Service) (Service, error)

func (*Service) BalanceUrl

func (service *Service) BalanceUrl() string

func (*Service) Call

func (service *Service) Call(method string, uri string, headers map[string]string, body string) *fasthttp.Response

func (*Service) GenerateId

func (service *Service) GenerateId() bson.ObjectId

func (*Service) GetGroup

func (service *Service) GetGroup() (ServiceGroup, error)

func (*Service) GetHost

func (service *Service) GetHost() string

func (*Service) GetManagementEndpoint

func (service *Service) GetManagementEndpoint(managementType string) string

func (*Service) GetManagementEndpointMethod

func (service *Service) GetManagementEndpointMethod(managementType string) string

func (*Service) IsReachableFromExternal

func (service *Service) IsReachableFromExternal(sd ServiceDiscovery) bool

func (*Service) NormalizeService

func (service *Service) NormalizeService()

func (*Service) ServiceManagementCall

func (service *Service) ServiceManagementCall(managementType string) (bool, string)

type ServiceDiscovery

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

func GetServiceDiscoveryObject

func GetServiceDiscoveryObject() *ServiceDiscovery

func (*ServiceDiscovery) AddServiceToGroup

func (sd *ServiceDiscovery) AddServiceToGroup(serviceGroupId string, serviceId string) error

func (*ServiceDiscovery) FindService

func (serviceDisc *ServiceDiscovery) FindService(service Service) (Service, error)

func (*ServiceDiscovery) FindServiceWithMatchingPrefix

func (serviceDisc *ServiceDiscovery) FindServiceWithMatchingPrefix(uri string) (Service, error)

func (*ServiceDiscovery) GetAllServices

func (serviceDisc *ServiceDiscovery) GetAllServices() ([]Service, error)

func (*ServiceDiscovery) GetEndpointForUri

func (serviceDisc *ServiceDiscovery) GetEndpointForUri(uri string) (Service, error)

func (*ServiceDiscovery) GetListOfServicesGroup

func (sd *ServiceDiscovery) GetListOfServicesGroup() ([]ServiceGroup, error)

func (*ServiceDiscovery) IsExternalRequest

func (service *ServiceDiscovery) IsExternalRequest(requestContxt *routing.Context) bool

func (*ServiceDiscovery) IsService

func (service *ServiceDiscovery) IsService() bool

func (*ServiceDiscovery) SaveServicesToFile

func (service *ServiceDiscovery) SaveServicesToFile()

func (*ServiceDiscovery) SetIsService

func (service *ServiceDiscovery) SetIsService(isServ bool)

func (*ServiceDiscovery) SetRegisteredServices

func (serviceDisc *ServiceDiscovery) SetRegisteredServices(rs []Service)

func (*ServiceDiscovery) UpdateService

func (serviceDisc *ServiceDiscovery) UpdateService(service Service) (Service, error)

type ServiceGroup

type ServiceGroup struct {
	Id           bson.ObjectId `bson:"_id" json:"Id"`
	Name         string
	IsReachable  bool
	HostsEnabled []string
	Services     []bson.ObjectId
}

func ValidateServiceGroupBody

func ValidateServiceGroupBody(c *routing.Context) (ServiceGroup, error)

func (*ServiceGroup) Contains

func (sg *ServiceGroup) Contains(s Service) bool

type ServicesConfig

type ServicesConfig struct {
	Services []Service `json:"services"`
}

func LoadServicesConfiguration

func LoadServicesConfiguration() ServicesConfig

Jump to

Keyboard shortcuts

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