calculator

package
v0.0.0-...-a7ed0dc Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 3 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventScore

func EventScore(e models.Event) int

Determine the score of an event. An event with higher score should be emitted before lower ones. The score based ordering ensures continuous routability, so events with running instances should be emitted first followed by remove events.

Types

type ActualLRPEventCalculator

type ActualLRPEventCalculator struct {
	// Deprecated: use ActualLRPInstanceHub instead
	ActualLRPGroupHub    events.Hub
	ActualLRPInstanceHub events.Hub
}

func (ActualLRPEventCalculator) EmitCrashEvents

func (e ActualLRPEventCalculator) EmitCrashEvents(traceId string, beforeSet, afterSet []*models.ActualLRP)

EmitCrashEvents emits only the events for a crash scenario. Specifically:

  • A CrashEvent each for the Group Hub and the Instance Hub
  • A ChangedEvent for the Group Hub
  • Either a ChangedEvent or a Removed and Created Event for the Instance Hub, depending on the state of the ActualLRP

This function was added to work around a bug in the existing logic for EmitEvents, where CrashedEvents were not being emitted due to the CrashResetTimeout

func (ActualLRPEventCalculator) EmitEvents

func (e ActualLRPEventCalculator) EmitEvents(traceId string, beforeSet, afterSet []*models.ActualLRP)

EmitEvents emits the events such as when the changes identified in the events are applied to the beforeSet the resulting state is equal to afterSet. The beforeSet and afterSet are assumed to have the same process guid and index.

func (ActualLRPEventCalculator) RecordChange

func (e ActualLRPEventCalculator) RecordChange(before, after *models.ActualLRP, lrps []*models.ActualLRP) []*models.ActualLRP

RecordChange returns a new LRP set with the before LRP replaced with after LRP. The index of after and before is the same. New LRPs (i.e. when before is nil) are appended to the end of the lrp slice.

Jump to

Keyboard shortcuts

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