archimedes

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixPath = "/archimedes"

	ServicesPath        = "/services"
	ServicePath         = "/services/%s"
	ServiceInstancePath = "/services/%s/%s"
	InstancePath        = "/instances/%s"
	DiscoverPath        = "/discover"
	WhoAreYouPath       = "/who"
	TablePath           = "/table"
	ResolvePath         = "/resolve"
)

Paths

View Source
const (
	ArchimedesServiceName = "archimedes"
	Port                  = 50000
)
View Source
const (
	ServiceIdPathVar  = "serviceId"
	InstanceIdPathVar = "instanceId"
)

Path variables

Variables

View Source
var (
	DefaultHostPort = ArchimedesServiceName + ":" + strconv.Itoa(Port)
)
View Source
var Routes = []utils.Route{
	{
		Name:        registerServiceName,
		Method:      http.MethodPost,
		Pattern:     serviceRoute,
		HandlerFunc: registerServiceHandler,
	},

	{
		Name:        deleteServiceName,
		Method:      http.MethodDelete,
		Pattern:     serviceRoute,
		HandlerFunc: deleteServiceHandler,
	},

	{
		Name:        registerServiceInstanceName,
		Method:      http.MethodPost,
		Pattern:     serviceInstanceRoute,
		HandlerFunc: registerServiceInstanceHandler,
	},

	{
		Name:        deleteServiceInstanceName,
		Method:      http.MethodDelete,
		Pattern:     serviceInstanceRoute,
		HandlerFunc: deleteServiceInstanceHandler,
	},

	{
		Name:        getAllServicesName,
		Method:      http.MethodGet,
		Pattern:     servicesRoute,
		HandlerFunc: getAllServicesHandler,
	},

	{
		Name:        getAllServiceInstancesName,
		Method:      http.MethodGet,
		Pattern:     serviceRoute,
		HandlerFunc: getAllServiceInstancesHandler,
	},

	{
		Name:        getInstanceName,
		Method:      http.MethodGet,
		Pattern:     instanceRoute,
		HandlerFunc: getInstanceHandler,
	},

	{
		Name:        getServiceInstanceName,
		Method:      http.MethodGet,
		Pattern:     serviceInstanceRoute,
		HandlerFunc: getServiceInstanceHandler,
	},

	{
		Name:        discoverName,
		Method:      http.MethodPost,
		Pattern:     discoverRoute,
		HandlerFunc: discoverHandler,
	},

	{
		Name:        whoAreYouName,
		Method:      http.MethodGet,
		Pattern:     whoAreYouRoute,
		HandlerFunc: whoAreYouHandler,
	},

	{
		Name:        getTableName,
		Method:      http.MethodGet,
		Pattern:     tableRoute,
		HandlerFunc: getServicesTableHandler,
	},

	{
		Name:        resolveName,
		Method:      http.MethodPost,
		Pattern:     resolveRoute,
		HandlerFunc: resolveHandler,
	},
}

Functions

func GetInstancePath

func GetInstancePath(instanceId string) string

func GetResolvePath

func GetResolvePath() string

func GetServiceInstancePath

func GetServiceInstancePath(serviceId, instanceId string) string

func GetServicePath

func GetServicePath(serviceId string) string

func GetServicesPath

func GetServicesPath() string

func ResolveServiceInArchimedes

func ResolveServiceInArchimedes(httpClient *http.Client, hostPort string) (string, error)

Types

type ServicesTable

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

func NewServicesTable

func NewServicesTable() *ServicesTable

func (*ServicesTable) AddInstance

func (st *ServicesTable) AddInstance(serviceId, instanceId string, instance *archimedes.Instance) (added bool)

func (*ServicesTable) AddService

func (st *ServicesTable) AddService(serviceId string, newEntry *archimedes.ServicesTableEntryDTO) (added bool)

func (*ServicesTable) DeleteInstance

func (st *ServicesTable) DeleteInstance(serviceId, instanceId string)

func (*ServicesTable) DeleteNeighborServices

func (st *ServicesTable) DeleteNeighborServices(neighborId string)

func (*ServicesTable) DeleteService

func (st *ServicesTable) DeleteService(serviceId string)

func (*ServicesTable) GetAllServiceInstances

func (st *ServicesTable) GetAllServiceInstances(serviceId string) map[string]*archimedes.Instance

func (*ServicesTable) GetAllServices

func (st *ServicesTable) GetAllServices() map[string]*archimedes.Service

func (*ServicesTable) GetInstance

func (st *ServicesTable) GetInstance(instanceId string) (instance *archimedes.Instance, ok bool)

func (*ServicesTable) GetService

func (st *ServicesTable) GetService(serviceId string) (service *archimedes.Service, ok bool)

func (*ServicesTable) GetServiceInstance

func (st *ServicesTable) GetServiceInstance(serviceId, instanceId string) (*archimedes.Instance, bool)

func (*ServicesTable) ServiceHasInstance

func (st *ServicesTable) ServiceHasInstance(serviceId, instanceId string) bool

func (*ServicesTable) ToDiscoverMsg

func (st *ServicesTable) ToDiscoverMsg(archimedesId string) *archimedes.DiscoverMsg

func (*ServicesTable) UpdateService

func (st *ServicesTable) UpdateService(serviceId string, newEntry *archimedes.ServicesTableEntryDTO) bool

func (*ServicesTable) UpdateTableWithDiscoverMessage

func (st *ServicesTable) UpdateTableWithDiscoverMessage(neighbor string,
	discoverMsg *archimedes.DiscoverMsg) (changed bool)

type ServicesTableEntry

type ServicesTableEntry struct {
	Host         *utils.Node
	Service      *archimedes.Service
	Instances    *sync.Map
	NumberOfHops int
	MaxHops      int
	Version      int
	EntryLock    *sync.RWMutex
}

func NewTempServiceTableEntry

func NewTempServiceTableEntry() *ServicesTableEntry

func (*ServicesTableEntry) ToDTO

Jump to

Keyboard shortcuts

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