network

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToEnvironmentVariables

func ConvertToEnvironmentVariables(nets []*runtimev1.NetworkMapping) ([]string, error)

ConvertToEnvironmentVariables converts NetworkMapping to environment variables

func GetFreePorts

func GetFreePorts(n int) ([]int, error)

GetFreePorts returns a slice of n free ports

func ToDns added in v0.0.31

func ToDns(e *basev1.Endpoint) string

func ToEndpoint

func ToEndpoint(endpoint *basev1.Endpoint) *configurations.Endpoint

func ToUnique

func ToUnique(endpoint *basev1.Endpoint) string

Types

type Address

type Address struct {
	Host string
	Port int
}

type ApplicationEndpoint

type ApplicationEndpoint struct {
	Service     string
	Application string
	Namespace   string
	Endpoint    *basev1.Endpoint
	PortBinding string // something like 8080/tcp
}

An ApplicationEndpoint takes a service Endpoint and embed it so it can be used across the applications

func (ApplicationEndpoint) Clone

func (ApplicationEndpoint) Unique

func (e ApplicationEndpoint) Unique() string

type ApplicationEndpointInstance

type ApplicationEndpointInstance struct {
	ApplicationEndpoint ApplicationEndpoint
	Port                int
	Host                string
}

An ApplicationEndpointInstance is an instance of an ApplicationEndpoint

func (*ApplicationEndpointInstance) Address

func (m *ApplicationEndpointInstance) Address() string

func (*ApplicationEndpointInstance) Name

func (*ApplicationEndpointInstance) StringPort

func (m *ApplicationEndpointInstance) StringPort() string

type ApplicationEndpointInstances

type ApplicationEndpointInstances struct {
	ApplicationEndpointInstances []*ApplicationEndpointInstance
}

func (*ApplicationEndpointInstances) Address

func (pm *ApplicationEndpointInstances) Address(endpoint *basev1.Endpoint) *Address

func (*ApplicationEndpointInstances) First

type DNS

type DNS struct{}

func (DNS) Reserve

type FixedStrategy

type FixedStrategy struct{}

func (FixedStrategy) Reserve

type RandomStrategy

type RandomStrategy struct{}

func (RandomStrategy) Reserve

type ServiceManager

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

A ServiceManager helps go from a service to applications endpoint instances

func NewServiceDnsManager

func NewServiceDnsManager(ctx context.Context, identity *servicev1.ServiceIdentity, endpoints ...*basev1.Endpoint) (*ServiceManager, error)

func NewServiceManager

func NewServiceManager(identity *servicev1.ServiceIdentity, endpoints ...*basev1.Endpoint) *ServiceManager

func NewServicePortManager

func NewServicePortManager(ctx context.Context, identity *servicev1.ServiceIdentity, endpoints ...*basev1.Endpoint) (*ServiceManager, error)

func (*ServiceManager) ApplicationEndpointInstance

func (pm *ServiceManager) ApplicationEndpointInstance(endpoint *basev1.Endpoint) (*ApplicationEndpointInstance, error)

func (*ServiceManager) ApplicationEndpointInstances

func (pm *ServiceManager) ApplicationEndpointInstances() []*ApplicationEndpointInstance

func (*ServiceManager) Bind

func (pm *ServiceManager) Bind(endpoint *basev1.Endpoint, portBinding string) error

func (*ServiceManager) Expose

func (pm *ServiceManager) Expose(endpoint *basev1.Endpoint) error

func (*ServiceManager) NetworkMapping

func (pm *ServiceManager) NetworkMapping() ([]*runtimev1.NetworkMapping, error)

NetworkMapping returns the network mapping for the service to be passed back to codefly

func (*ServiceManager) Port

func (pm *ServiceManager) Port(endpoint *basev1.Endpoint) (int, error)

func (*ServiceManager) Reserve

func (pm *ServiceManager) Reserve() error

type Strategy

type Strategy interface {
	Reserve(host string, endpoints []ApplicationEndpoint) (*ApplicationEndpointInstances, error)
}

Jump to

Keyboard shortcuts

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