Documentation
¶
Index ¶
- Variables
- func CountPaths(g *simple.DirectedGraph)
- func DFSWithMemoization(g *simple.DirectedGraph, nodeID int64, memo map[int64]map[int64]int)
- func ParseYAML(filePath string) (*simple.DirectedGraph, map[int64][]int64, error)
- type BasicComponent
- type Component
- type ComponentDependency
- type ComponentState
- type CompositeKey
- type LiveVersion
- type OperationType
- type Request
- type RequestType
- type Signal
- type Supervisor
- type SupervisorInterface
Constants ¶
This section is empty.
Variables ¶
var ComponentToId = map[string]int{} //Gives the component id (int) when the name is passed
var IdToComponent = map[int]string{} //Gives the component name (string)
Functions ¶
func CountPaths ¶
func CountPaths(g *simple.DirectedGraph)
CountPaths calculates the waiting count for each component based on its dependencies
func DFSWithMemoization ¶
DFSWithMemoization performs a DFS to calculate paths from the node to its ancestors.
Types ¶
type BasicComponent ¶
type BasicComponent struct { CompId int InChannel chan interface{} OutChannel []chan interface{} State ComponentState // Field to track component state StateMutex sync.Mutex // Mutex to protect state changes DirtyFlag bool }
BasicComponent represents a single component with channels and implements the Component interface.
func (*BasicComponent) Cancel ¶ added in v1.0.11
func (c *BasicComponent) Cancel()
Cancel is a placeholder for the user-defined request cancellation method.
func (*BasicComponent) GetLiveVersion ¶
func (c *BasicComponent) GetLiveVersion() int
func (*BasicComponent) GetStagingData ¶
func (c *BasicComponent) GetStagingData() interface{}
func (*BasicComponent) GetStagingVersion ¶
func (c *BasicComponent) GetStagingVersion() int
func (*BasicComponent) ProcessReq ¶
func (c *BasicComponent) ProcessReq(req Request[interface{}])
ProcessReq processes requests
func (*BasicComponent) Sync ¶
func (c *BasicComponent) Sync()
Sync is a placeholder for the user-defined synchronization method.
type Component ¶
type Component interface { GetLiveVersion() int GetStagingVersion() int GetStagingData() interface{} ProcessReq(req Request[interface{}]) Cancel() Sync() // contains filtered or unexported methods }
Component interface defines the behavior that all components must implement.
type ComponentDependency ¶
type ComponentState ¶
type ComponentState int
ComponentState defines the possible states of a component
const ( Idle ComponentState = iota Running Cancelled )
type CompositeKey ¶
type CompositeKey struct {
// contains filtered or unexported fields
}
type Request ¶
type Request[T any] struct { ReqType RequestType SourceCompId int ComponentName string Operation OperationType Data T Index int }
Request encapsulates the details of a request being sent.
type Signal ¶
type Signal struct { SigType RequestType SourceCompId int CompId int State ComponentState }
Signal represents a signal sent between component and Supervisor
type Supervisor ¶
type Supervisor struct { CompId int InChannel chan interface{} OutChannelMap map[int]chan interface{} RequestQueue []Request[interface{}] QueueMutex sync.Mutex // To protect access to the queue TaskList map[int][]int //Maintains current ongoing tasks DoneList map[int][]int SwitchList map[int][]int //Contains the list of components that are done switching // contains filtered or unexported fields }
func InitializeComponents ¶
func InitializeComponents(filePath string, userComps []Component, switchCount int) *Supervisor
InitializeComponents initializes and starts the components based on dependencies.
func (*Supervisor) CancelReq ¶
func (s *Supervisor) CancelReq(componentName string)
func (*Supervisor) SendReq ¶
func (s *Supervisor) SendReq(compName string, operation OperationType, data interface{}, index int) bool
SendReq adds the request to the queue
type SupervisorInterface ¶
type SupervisorInterface interface { SendReq(compName string, operation OperationType, data interface{}, index int) bool CancelReq(componentName string) // contains filtered or unexported methods }