models

package
v0.0.0-...-d8c349a Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 104

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FailOnRouterPortConflicts = false
View Source
var InvalidPortError = errors.New("Port must be between 1024 and 65535")
View Source
var ReservedSystemComponentPorts = []uint16{}

Functions

This section is empty.

Types

type Model

type Model struct {
	Guid      string    `gorm:"primary_key" json:"-"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

type ModificationTag

type ModificationTag struct {
	Guid  string `gorm:"column:modification_guid" json:"guid"`
	Index uint32 `gorm:"column:modification_index" json:"index"`
}

func NewModificationTag

func NewModificationTag() (ModificationTag, error)

func (*ModificationTag) Increment

func (t *ModificationTag) Increment()

func (*ModificationTag) SucceededBy

func (m *ModificationTag) SucceededBy(other *ModificationTag) bool

type Range

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

func NewRange

func NewRange(start, end uint16) (Range, error)

func (Range) Endpoints

func (r Range) Endpoints() (uint16, uint16)

func (Range) Overlaps

func (r Range) Overlaps(other Range) bool

func (Range) String

func (r Range) String() string

type Ranges

type Ranges []Range

type ReservablePorts

type ReservablePorts string

func (ReservablePorts) Parse

func (p ReservablePorts) Parse() (Ranges, error)

func (*ReservablePorts) UnmarshalYAML

func (p *ReservablePorts) UnmarshalYAML(unmarshal func(interface{}) error) error

func (ReservablePorts) Validate

func (p ReservablePorts) Validate() error

type Route

type Route struct {
	Model
	ExpiresAt time.Time `json:"-"`
	RouteEntity
}

func NewRoute

func NewRoute(url string, port uint16, ip, logGuid, routeServiceUrl string, ttl int) Route

func NewRouteWithModel

func NewRouteWithModel(route Route) (Route, error)

func (Route) GetTTL

func (r Route) GetTTL() int

func (*Route) SetDefaults

func (r *Route) SetDefaults(defaultTTL int)

type RouteEntity

type RouteEntity struct {
	Route           string `gorm:"not null; unique_index:idx_route" json:"route"`
	Port            uint16 `gorm:"not null; unique_index:idx_route" json:"port"`
	IP              string `gorm:"not null; unique_index:idx_route" json:"ip"`
	TTL             *int   `json:"ttl"`
	LogGuid         string `json:"log_guid"`
	RouteServiceUrl string `gorm:"not null; unique_index:idx_route" json:"route_service_url,omitempty"`
	ModificationTag `json:"modification_tag"`
}

type RouterGroup

type RouterGroup struct {
	Model
	Guid            string          `json:"guid"`
	Name            string          `json:"name"`
	Type            RouterGroupType `json:"type"`
	ReservablePorts ReservablePorts `json:"reservable_ports" yaml:"reservable_ports"`
}

func (RouterGroup) Validate

func (g RouterGroup) Validate() error

type RouterGroupDB

type RouterGroupDB struct {
	Model
	Name            string
	Type            string
	ReservablePorts string
}

func NewRouterGroupDB

func NewRouterGroupDB(routerGroup RouterGroup) RouterGroupDB

func (RouterGroupDB) TableName

func (RouterGroupDB) TableName() string

func (*RouterGroupDB) ToRouterGroup

func (rg *RouterGroupDB) ToRouterGroup() RouterGroup

type RouterGroupType

type RouterGroupType string
const (
	RouterGroup_TCP  RouterGroupType = "tcp"
	RouterGroup_HTTP RouterGroupType = "http"
)

type RouterGroups

type RouterGroups []RouterGroup

func (RouterGroups) Validate

func (g RouterGroups) Validate() error

type RouterGroupsDB

type RouterGroupsDB []RouterGroupDB

func (RouterGroupsDB) ToRouterGroups

func (rgs RouterGroupsDB) ToRouterGroups() RouterGroups

type TcpMappingEntity

type TcpMappingEntity struct {
	RouterGroupGuid string  `gorm:"not null; unique_index:idx_tcp_route" json:"router_group_guid"`
	HostPort        uint16  `gorm:"not null; unique_index:idx_tcp_route; type:int" json:"backend_port"`
	HostTLSPort     int     `gorm:"default:null; unique_index:idx_tcp_route; type:int" json:"backend_tls_port"`
	HostIP          string  `gorm:"not null; unique_index:idx_tcp_route" json:"backend_ip"`
	SniHostname     *string `gorm:"default:null; unique_index:idx_tcp_route" json:"backend_sni_hostname,omitempty"`
	// We don't add uniqueness on InstanceId so that if a route is attempted to be created with the same detals but
	// different InstanceId, we fail uniqueness and prevent stale/duplicate routes. If this fails a route, the
	// TTL on the old record should expire + allow the new route to be created eventually.
	InstanceId       string `gorm:"null; default:null;" json:"instance_id"`
	ExternalPort     uint16 `gorm:"not null; unique_index:idx_tcp_route; type: int" json:"port"`
	ModificationTag  `json:"modification_tag"`
	TTL              *int   `json:"ttl,omitempty"`
	IsolationSegment string `json:"isolation_segment"`
}

IMPORTANT!! when adding a new field here that is part of the unique index for

a tcp route, make sure to update not only the logic for Matches(),
but also the SqlDb.FindExistingTcpRouteMapping() function's custom
WHERE filter to include the new field

type TcpRouteMapping

type TcpRouteMapping struct {
	Model
	ExpiresAt time.Time `json:"-"`
	TcpMappingEntity
}

func NewTcpRouteMapping

func NewTcpRouteMapping(
	routerGroupGuid string,
	externalPort uint16,
	hostIP string,
	hostPort uint16,
	hostTlsPort int,
	instanceId string,
	sniHostname *string,
	ttl int,
	modTag ModificationTag,
) TcpRouteMapping

func NewTcpRouteMappingWithModel

func NewTcpRouteMappingWithModel(tcpMapping TcpRouteMapping) (TcpRouteMapping, error)

func (TcpRouteMapping) Matches

func (m TcpRouteMapping) Matches(other TcpRouteMapping) bool

func (*TcpRouteMapping) SetDefaults

func (t *TcpRouteMapping) SetDefaults(maxTTL int)

func (TcpRouteMapping) String

func (m TcpRouteMapping) String() string

func (TcpRouteMapping) TableName

func (TcpRouteMapping) TableName() string

Jump to

Keyboard shortcuts

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