Documentation ¶
Overview ¶
nolint // TODO
Index ¶
- Constants
- Variables
- func AssignCrane(hubID string, crane *Crane)
- func GetAllAssignedCranes() map[string]*Crane
- func ImportAndVerifyHubInfo(ctx context.Context, hubID string, announcementData, statusData []byte, ...) (h *hub.Hub, forward bool, tErr *terminal.Error)
- func MeasureHub(ctx context.Context, h *hub.Hub, checkExpiryWith time.Duration) *terminal.Error
- func RegisterCraneUpdateHook(fn func(crane *Crane))
- type BlockingSubmitQueue
- type BlockingSubmitter
- type CapacityTestOp
- type CapacityTestOptions
- type Crane
- func (crane *Crane) AbandonTerminal(id uint32, err *terminal.Error)
- func (crane *Crane) AbortStopping() (aborted bool)
- func (crane *Crane) Authenticated() bool
- func (crane *Crane) EstablishNewTerminal(localTerm terminal.TerminalInterface, initData *container.Container) *terminal.Error
- func (crane *Crane) IsMine() bool
- func (crane *Crane) IsStopping() bool
- func (crane *Crane) LocalAddr() net.Addr
- func (crane *Crane) MarkStopping() (stopping bool)
- func (crane *Crane) NotifyUpdate()
- func (crane *Crane) Public() bool
- func (crane *Crane) Publish() error
- func (crane *Crane) RemoteAddr() net.Addr
- func (crane *Crane) Start() error
- func (crane *Crane) Stop(err *terminal.Error)
- func (crane *Crane) Stopped() bool
- func (crane *Crane) String() string
- func (crane *Crane) Transport() *hub.Transport
- func (crane *Crane) VerifyConnectedHub() error
- type CraneControllerTerminal
- func (controller *CraneControllerTerminal) Abandon(err *terminal.Error)
- func (controller *CraneControllerTerminal) Deliver(c *container.Container) *terminal.Error
- func (controller *CraneControllerTerminal) Flush()
- func (controller *CraneControllerTerminal) SyncState(ctx context.Context) *terminal.Error
- type CraneTerminal
- func (t *CraneTerminal) Abandon(err *terminal.Error)
- func (t *CraneTerminal) Deliver(c *container.Container) *terminal.Error
- func (t *CraneTerminal) Flush()
- func (t *CraneTerminal) GrantPermission(grant terminal.Permission)
- func (t *CraneTerminal) IsAbandoned() bool
- func (t *CraneTerminal) LocalAddr() net.Addr
- func (t *CraneTerminal) RemoteAddr() net.Addr
- func (t *CraneTerminal) Transport() *hub.Transport
- type ExpandOp
- type ExpansionRelayTerminal
- type ExpansionTerminal
- func (t *ExpansionTerminal) Abandon(err *terminal.Error)
- func (t *ExpansionTerminal) Deliver(c *container.Container) *terminal.Error
- func (t *ExpansionTerminal) End(err *terminal.Error)
- func (t *ExpansionTerminal) Flush()
- func (t *ExpansionTerminal) FmtID() string
- func (t *ExpansionTerminal) HasEnded(end bool) bool
- func (t *ExpansionTerminal) ID() uint32
- func (t *ExpansionTerminal) IsAbandoned() bool
- func (t *ExpansionTerminal) SetChangeNotifyFunc(f func())
- func (t *ExpansionTerminal) SetID(id uint32)
- func (t *ExpansionTerminal) Type() string
- type LatencyTestClientOp
- type LatencyTestOp
- type NetworkOptimizationState
- func (netState *NetworkOptimizationState) GetTrafficStats() (lifetimeBytesIn uint64, lifetimeBytesOut uint64, lifetimeStarted time.Time, ...)
- func (netState *NetworkOptimizationState) LapsePeriod()
- func (netState *NetworkOptimizationState) LastSuggestedAt() time.Time
- func (netState *NetworkOptimizationState) MarkedStoppingAt() time.Time
- func (netState *NetworkOptimizationState) ReportTraffic(bytes uint64, in bool)
- func (netState *NetworkOptimizationState) UpdateLastSuggestedAt()
- func (netState *NetworkOptimizationState) UpdateMarkedStoppingAt()
- type SyncStateMessage
- type SyncStateOp
Constants ¶
const ( CraneMsgTypeEnd = 0 CraneMsgTypeInfo = 1 CraneMsgTypeRequestHubInfo = 2 CraneMsgTypeVerify = 3 CraneMsgTypeStartEncrypted = 4 CraneMsgTypeStartUnencrypted = 5 )
Crane Msg Types.
const ( CraneMeasurementTTLDefault = 30 * time.Minute CraneMeasurementTTLByCostBase = 1 * time.Minute CraneMeasurementTTLByCostMin = 30 * time.Minute CraneMeasurementTTLByCostMax = 3 * time.Hour )
Measurement Configuration.
const (
// CapacityTestOpType is the type ID of the capacity test operation.
CapacityTestOpType = "capacity"
)
const ExpandOpType string = "expand"
ExpandOpType is the type ID of the expand operation.
const (
// LatencyTestOpType is the type ID of the latency test operation.
LatencyTestOpType = "latency"
)
const NetStatePeriodInterval = 15 * time.Minute
NetStatePeriodInterval defines the interval some of the net state should be reset.
const (
// QOTD holds the quote of the day to return on idling unused connections.
QOTD = "Privacy is not an option, and it shouldn't be the price we accept for just getting on the Internet.\nGary Kovacs\n"
)
const SyncStateOpType = "sync/state"
SyncStateOpType is the type ID of the sync state operation.
Variables ¶
var (
ErrDone = errors.New("crane is done")
)
Errors.
Functions ¶
func AssignCrane ¶
AssignCrane assigns a crane to the given Hub ID.
func GetAllAssignedCranes ¶ added in v0.3.5
GetAllAssignedCranes returns a copy of the map of all assigned cranes.
func ImportAndVerifyHubInfo ¶ added in v0.3.0
func ImportAndVerifyHubInfo(ctx context.Context, hubID string, announcementData, statusData []byte, mapName string, scope hub.Scope) (h *hub.Hub, forward bool, tErr *terminal.Error)
ImportAndVerifyHubInfo imports the given hub message and verifies them.
func MeasureHub ¶ added in v0.3.13
MeasureHub measures the connection to this Hub and saves the results to the Hub.
func RegisterCraneUpdateHook ¶ added in v0.3.0
func RegisterCraneUpdateHook(fn func(crane *Crane))
RegisterCraneUpdateHook allows the captain to hook into receiving updates for cranes.
Types ¶
type BlockingSubmitQueue ¶ added in v0.3.0
type BlockingSubmitQueue struct {
// contains filtered or unexported fields
}
func NewBlockingSubmitQueue ¶ added in v0.3.0
func NewBlockingSubmitQueue(size int) *BlockingSubmitQueue
type BlockingSubmitter ¶ added in v0.3.0
type BlockingSubmitter struct {
// contains filtered or unexported fields
}
type CapacityTestOp ¶ added in v0.3.11
CapacityTestOp is used for capacity test operations.
func NewCapacityTestOp ¶ added in v0.3.11
func NewCapacityTestOp(t terminal.OpTerminal, opts *CapacityTestOptions) (*CapacityTestOp, *terminal.Error)
NewCapacityTestOp runs a capacity test.
func (*CapacityTestOp) Deliver ¶ added in v0.3.11
func (op *CapacityTestOp) Deliver(c *container.Container) *terminal.Error
Deliver delivers a message.
func (*CapacityTestOp) End ¶ added in v0.3.11
func (op *CapacityTestOp) End(tErr *terminal.Error)
End ends the operation.
func (*CapacityTestOp) Result ¶ added in v0.3.11
func (op *CapacityTestOp) Result() <-chan *terminal.Error
Result returns the result (end error) of the operation.
func (*CapacityTestOp) Type ¶ added in v0.3.11
func (op *CapacityTestOp) Type() string
Type returns the type ID.
type CapacityTestOptions ¶ added in v0.3.11
type CapacityTestOptions struct { TestVolume int MaxTime time.Duration // contains filtered or unexported fields }
CapacityTestOptions holds options for the capacity test.
type Crane ¶
type Crane struct { // ID is the ID of the Crane. ID string // ConnectedHub is the identity of the remote Hub. ConnectedHub *hub.Hub // NetState holds the network optimization state. // It must always be set and the reference must not be changed. // Access to fields within are coordinated by itself. NetState *NetworkOptimizationState // Controller is the Crane's Controller Terminal. Controller *CraneControllerTerminal // contains filtered or unexported fields }
Crane is the primary duplexer and connection manager.
func GetAssignedCrane ¶
GetAssignedCrane returns the assigned crane of the given Hub ID.
func NewCrane ¶
func NewCrane(ctx context.Context, ship ships.Ship, connectedHub *hub.Hub, id *cabin.Identity) (*Crane, error)
NewCrane returns a new crane.
func (*Crane) AbandonTerminal ¶ added in v0.3.0
AbandonTerminal abandons the terminal with the given ID.
func (*Crane) AbortStopping ¶ added in v0.3.18
AbortStopping aborts the stopping.
func (*Crane) Authenticated ¶ added in v0.3.13
Authenticated returns whether the other side of the crane has authenticated itself with an access code.
func (*Crane) EstablishNewTerminal ¶ added in v0.3.0
func (crane *Crane) EstablishNewTerminal( localTerm terminal.TerminalInterface, initData *container.Container, ) *terminal.Error
EstablishNewTerminal establishes a new terminal with the crane.
func (*Crane) IsStopping ¶ added in v0.3.18
IsStopping returns whether the crane is stopping.
func (*Crane) MarkStopping ¶ added in v0.3.18
MarkStopping marks the crane as stopping.
func (*Crane) NotifyUpdate ¶ added in v0.3.0
func (crane *Crane) NotifyUpdate()
NotifyUpdate calls the registers crane update hook function.
func (*Crane) RemoteAddr ¶ added in v0.3.0
RemoteAddr returns ship's local address.
func (*Crane) VerifyConnectedHub ¶ added in v0.3.0
VerifyConnectedHub verifies the connected Hub.
type CraneControllerTerminal ¶ added in v0.3.0
type CraneControllerTerminal struct { *terminal.TerminalBase *terminal.DuplexFlowQueue Crane *Crane }
CraneControllerTerminal is a terminal for the crane itself.
func NewLocalCraneControllerTerminal ¶ added in v0.3.0
func NewLocalCraneControllerTerminal( crane *Crane, initMsg *terminal.TerminalOpts, ) (*CraneControllerTerminal, *container.Container, *terminal.Error)
NewLocalCraneControllerTerminal returns a new local crane controller.
func NewRemoteCraneControllerTerminal ¶ added in v0.3.0
func NewRemoteCraneControllerTerminal( crane *Crane, initData *container.Container, ) (*CraneControllerTerminal, *terminal.TerminalOpts, *terminal.Error)
NewRemoteCraneControllerTerminal returns a new remote crane controller.
func (*CraneControllerTerminal) Abandon ¶ added in v0.3.0
func (controller *CraneControllerTerminal) Abandon(err *terminal.Error)
Abandon abandons the crane controller.
func (*CraneControllerTerminal) Deliver ¶ added in v0.3.0
func (controller *CraneControllerTerminal) Deliver(c *container.Container) *terminal.Error
Deliver delivers a message to the crane controller.
func (*CraneControllerTerminal) Flush ¶ added in v0.3.11
func (controller *CraneControllerTerminal) Flush()
Flush flushes the crane controller's terminal and flow queue.
type CraneTerminal ¶ added in v0.3.0
type CraneTerminal struct { *terminal.TerminalBase *terminal.DuplexFlowQueue // contains filtered or unexported fields }
CraneTerminal is a terminal started by a crane.
func NewLocalCraneTerminal ¶ added in v0.3.0
func NewLocalCraneTerminal( crane *Crane, remoteHub *hub.Hub, initMsg *terminal.TerminalOpts, submitUpstream func(*container.Container), ) (*CraneTerminal, *container.Container, *terminal.Error)
NewLocalCraneTerminal returns a new local crane terminal.
func NewRemoteCraneTerminal ¶ added in v0.3.0
func NewRemoteCraneTerminal( crane *Crane, id uint32, initData *container.Container, ) (*CraneTerminal, *terminal.TerminalOpts, *terminal.Error)
NewRemoteCraneTerminal returns a new remote crane terminal.
func (*CraneTerminal) Abandon ¶ added in v0.3.0
func (t *CraneTerminal) Abandon(err *terminal.Error)
Abandon abandons the crane terminal.
func (*CraneTerminal) Deliver ¶ added in v0.3.0
func (t *CraneTerminal) Deliver(c *container.Container) *terminal.Error
Deliver delivers a message to the crane terminal.
func (*CraneTerminal) Flush ¶ added in v0.3.11
func (t *CraneTerminal) Flush()
Flush flushes the terminal and its flow queue.
func (*CraneTerminal) GrantPermission ¶ added in v0.3.13
func (t *CraneTerminal) GrantPermission(grant terminal.Permission)
GrantPermission grants the given permissions. Additionally, it will mark the crane as authenticated, if not public.
func (*CraneTerminal) IsAbandoned ¶ added in v0.3.0
func (t *CraneTerminal) IsAbandoned() bool
IsAbandoned returns whether the crane has been abandoned.
func (*CraneTerminal) LocalAddr ¶ added in v0.3.0
func (t *CraneTerminal) LocalAddr() net.Addr
LocalAddr returns the crane's local address.
func (*CraneTerminal) RemoteAddr ¶ added in v0.3.0
func (t *CraneTerminal) RemoteAddr() net.Addr
RemoteAddr returns the crane's remote address.
func (*CraneTerminal) Transport ¶ added in v0.3.7
func (t *CraneTerminal) Transport() *hub.Transport
Transport returns the crane's transport.
type ExpandOp ¶ added in v0.3.0
type ExpandOp struct { terminal.OpBase *terminal.DuplexFlowQueue // contains filtered or unexported fields }
ExpandOp is used to expand to another Hub.
type ExpansionRelayTerminal ¶ added in v0.3.0
type ExpansionRelayTerminal struct { *terminal.DuplexFlowQueue // contains filtered or unexported fields }
ExpansionRelayTerminal is a relay used for expansion.
func (*ExpansionRelayTerminal) Abandon ¶ added in v0.3.0
func (t *ExpansionRelayTerminal) Abandon(err *terminal.Error)
Abandon abandons the expansion.
func (*ExpansionRelayTerminal) Ctx ¶ added in v0.3.0
func (t *ExpansionRelayTerminal) Ctx() context.Context
Ctx returns the relay terminal context.
func (*ExpansionRelayTerminal) FmtID ¶ added in v0.3.0
func (t *ExpansionRelayTerminal) FmtID() string
FmtID returns the expansion ID hierarchy.
func (*ExpansionRelayTerminal) ID ¶ added in v0.3.0
func (t *ExpansionRelayTerminal) ID() uint32
ID returns the operation ID.
type ExpansionTerminal ¶ added in v0.3.0
type ExpansionTerminal struct { *terminal.TerminalBase *terminal.DuplexFlowQueue // contains filtered or unexported fields }
ExpansionTerminal is used for expanding to another Hub.
func ExpandTo ¶ added in v0.3.0
func ExpandTo(t terminal.OpTerminal, routeTo string, encryptFor *hub.Hub) (*ExpansionTerminal, *terminal.Error)
ExpandTo initiates an expansion.
func (*ExpansionTerminal) Abandon ¶ added in v0.3.0
func (t *ExpansionTerminal) Abandon(err *terminal.Error)
Abandon ends the terminal.
func (*ExpansionTerminal) Deliver ¶ added in v0.3.0
func (t *ExpansionTerminal) Deliver(c *container.Container) *terminal.Error
Deliver delivers a message to the next local stage.
func (*ExpansionTerminal) End ¶ added in v0.3.0
func (t *ExpansionTerminal) End(err *terminal.Error)
End ends the operation.
func (*ExpansionTerminal) Flush ¶ added in v0.3.11
func (t *ExpansionTerminal) Flush()
Flush flushes the terminal and flow queue.
func (*ExpansionTerminal) FmtID ¶ added in v0.3.0
func (t *ExpansionTerminal) FmtID() string
FmtID formats the operation ID.
func (*ExpansionTerminal) HasEnded ¶ added in v0.3.0
func (t *ExpansionTerminal) HasEnded(end bool) bool
HasEnded returns whether the operation has ended.
func (*ExpansionTerminal) ID ¶ added in v0.3.0
func (t *ExpansionTerminal) ID() uint32
ID returns the operation ID.
func (*ExpansionTerminal) IsAbandoned ¶ added in v0.3.0
func (t *ExpansionTerminal) IsAbandoned() bool
IsAbandoned returns whether the terminal has been abandoned.
func (*ExpansionTerminal) SetChangeNotifyFunc ¶ added in v0.3.7
func (t *ExpansionTerminal) SetChangeNotifyFunc(f func())
SetChangeNotifyFunc sets a callback function that is called when the terminal state changes.
func (*ExpansionTerminal) SetID ¶ added in v0.3.0
func (t *ExpansionTerminal) SetID(id uint32)
SetID sets the operation ID.
func (*ExpansionTerminal) Type ¶ added in v0.3.0
func (t *ExpansionTerminal) Type() string
Type returns the type ID.
type LatencyTestClientOp ¶ added in v0.3.11
type LatencyTestClientOp struct { LatencyTestOp // contains filtered or unexported fields }
LatencyTestClientOp is the client version of LatencyTestOp.
func NewLatencyTestOp ¶ added in v0.3.11
func NewLatencyTestOp(t terminal.OpTerminal) (*LatencyTestClientOp, *terminal.Error)
NewLatencyTestOp runs a latency test.
func (*LatencyTestClientOp) Deliver ¶ added in v0.3.11
func (op *LatencyTestClientOp) Deliver(c *container.Container) *terminal.Error
Deliver delivers a message to the operation.
func (*LatencyTestClientOp) End ¶ added in v0.3.11
func (op *LatencyTestClientOp) End(tErr *terminal.Error)
End ends the operation.
func (*LatencyTestClientOp) Result ¶ added in v0.3.11
func (op *LatencyTestClientOp) Result() <-chan *terminal.Error
Result returns the result (end error) of the operation.
type LatencyTestOp ¶ added in v0.3.11
LatencyTestOp is used to measure latency.
func (*LatencyTestOp) Deliver ¶ added in v0.3.11
func (op *LatencyTestOp) Deliver(c *container.Container) *terminal.Error
Deliver delivers a message to the operation.
func (*LatencyTestOp) End ¶ added in v0.3.11
func (op *LatencyTestOp) End(tErr *terminal.Error)
End ends the operation.
func (*LatencyTestOp) Type ¶ added in v0.3.11
func (op *LatencyTestOp) Type() string
Type returns the type ID.
type NetworkOptimizationState ¶ added in v0.3.13
type NetworkOptimizationState struct {
// contains filtered or unexported fields
}
NetworkOptimizationState holds data for optimization purposes.
func (*NetworkOptimizationState) GetTrafficStats ¶ added in v0.3.14
func (netState *NetworkOptimizationState) GetTrafficStats() ( lifetimeBytesIn uint64, lifetimeBytesOut uint64, lifetimeStarted time.Time, periodBytesIn uint64, periodBytesOut uint64, periodStarted time.Time, )
GetTrafficStats returns the traffic stats.
func (*NetworkOptimizationState) LapsePeriod ¶ added in v0.3.14
func (netState *NetworkOptimizationState) LapsePeriod()
LapsePeriod lapses the net state period, if needed.
func (*NetworkOptimizationState) LastSuggestedAt ¶ added in v0.3.13
func (netState *NetworkOptimizationState) LastSuggestedAt() time.Time
LastSuggestedAt returns when the lane was last suggested.
func (*NetworkOptimizationState) MarkedStoppingAt ¶ added in v0.3.18
func (netState *NetworkOptimizationState) MarkedStoppingAt() time.Time
MarkedStoppingAt returns when the lane was last marked as stopping.
func (*NetworkOptimizationState) ReportTraffic ¶ added in v0.3.14
func (netState *NetworkOptimizationState) ReportTraffic(bytes uint64, in bool)
ReportTraffic adds the reported transferred data to the traffic stats.
func (*NetworkOptimizationState) UpdateLastSuggestedAt ¶ added in v0.3.13
func (netState *NetworkOptimizationState) UpdateLastSuggestedAt()
UpdateLastSuggestedAt sets when the lane was last suggested to the current time.
func (*NetworkOptimizationState) UpdateMarkedStoppingAt ¶ added in v0.3.18
func (netState *NetworkOptimizationState) UpdateMarkedStoppingAt()
UpdateMarkedStoppingAt setse when the lane was last marked as stopping to the current time.
type SyncStateMessage ¶ added in v0.3.18
type SyncStateMessage struct {
Stopping bool
}
SyncStateMessage holds the sync data.
type SyncStateOp ¶ added in v0.3.18
SyncStateOp is used to sync the crane state.
func (*SyncStateOp) Deliver ¶ added in v0.3.18
func (op *SyncStateOp) Deliver(c *container.Container) *terminal.Error
Deliver delivers a message to the operation.
func (*SyncStateOp) End ¶ added in v0.3.18
func (op *SyncStateOp) End(tErr *terminal.Error)
End ends the operation.
func (*SyncStateOp) Type ¶ added in v0.3.18
func (op *SyncStateOp) Type() string
Type returns the type ID.