event

package
v0.0.0-...-c156f7f Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PTPNamespace = "openshift"
	PTPSubsystem = "ptp"
)
View Source
const (
	OFFSET     ValueType = "offset"
	STATE      ValueType = "state"
	GPS_STATUS ValueType = "gnss_status"
	//Status           ValueType = "status"
	PHASE_STATUS         ValueType = "phase_status"
	FREQUENCY_STATUS     ValueType = "frequency_status"
	NMEA_STATUS          ValueType = "nmea_status"
	PROCESS_STATUS       ValueType = "process_status"
	PPS_STATUS           ValueType = "pps_status"
	GM_INTERFACE_UNKNOWN string    = "unknown"
	DEVICE               ValueType = "device"
	QL                   ValueType = "ql"
	EXT_QL               ValueType = "ext_ql"
	CLOCK_QUALITY        ValueType = "clock_quality"
	NETWORK_OPTION       ValueType = "network_option"
	EEC_STATE                      = "eec_state"
)
View Source
const PTP4lProcessName = "ptp4l"

PTP4lProcessName ...

View Source
const SYNCEProcessName = "synce"

SYNCEProcessName ...

View Source
const TS2PHCProcessName = "ts2phc"

TS2PHCProcessName ...

Variables

View Source
var (
	PMCGMGetter = func(cfgName string) (protocol.GrandmasterSettings, error) {
		cfgName = strings.Replace(cfgName, TS2PHCProcessName, PTP4lProcessName, 1)
		return pmc.RunPMCExpGetGMSettings(cfgName)
	}
	PMCGMSetter = func(cfgName string, g protocol.GrandmasterSettings) error {
		cfgName = strings.Replace(cfgName, TS2PHCProcessName, PTP4lProcessName, 1)
		err := pmc.RunPMCExpSetGMSettings(cfgName, g)
		if err != nil {
			return fmt.Errorf("failed to update GRANDMASTER_SETTINGS_NP: %s", err)
		}
		return nil
	}
)

Functions

This section is empty.

Types

type ClockClassRequest

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

ClockClassRequest ...

type ClockType

type ClockType string

ClockType ...

const (
	// GM ..
	GM ClockType = "GM"
	// BC ...
	BC ClockType = "BC"
	// OC ...
	OC ClockType = "OC"
)

type DDetails

type DDetails []*DataDetails

type Data

type Data struct {
	ProcessName EventSource // ts2phc  // dpll
	Details     DDetails    // array of iface and  offset
	State       PTPState    // have the worst state here
	// contains filtered or unexported fields
}

Data ...

func (*Data) AddEvent

func (d *Data) AddEvent(event EventChannel)

func (*Data) GetDataDetails

func (d *Data) GetDataDetails(iface string) *DataDetails

GetDataDetails ...

func (*Data) UpdateState

func (d *Data) UpdateState()

UpdateState .. update process state

type DataDetails

type DataDetails struct {
	IFace     string
	State     PTPState
	ClockType ClockType
	Metrics   map[ValueType]DataMetric
	// contains filtered or unexported fields
}

DataDetails .. details for data

type DataMetric

type DataMetric struct {
	GaugeMetric   *prometheus.GaugeVec
	CounterMetric *prometheus.Counter
	Name          string
	ValueType     prometheus.ValueType
	Labels        prometheus.Labels
	Value         float64
	// contains filtered or unexported fields
}

DataMetrics ...

type EventChannel

type EventChannel struct {
	ProcessName        EventSource               // ptp4l, gnss etc
	State              PTPState                  // PTP locked etc
	IFace              string                    // Interface that is causing the event
	CfgName            string                    // ptp config profile name
	Values             map[ValueType]interface{} // either offset or status , 3 information  offset , phase state and frequency state
	ClockType          ClockType                 // oc bc gm
	Time               int64                     // time.Unix.Now()
	OutOfSpec          bool                      // out of Spec for offset
	WriteToLog         bool                      // send to log in predefined format %s[%d]:[%s] %s %d
	Reset              bool                      // reset data on ptp deletes or process died
	SourceLost         bool
	FrequencyTraceable bool // will be tru if synce is traceable
}

EventChannel .. event channel to subscriber to events

func (*EventChannel) GetLogData

func (e *EventChannel) GetLogData() string

type EventHandler

type EventHandler struct {
	sync.Mutex

	ReduceLog bool // reduce logs for every announce
	// contains filtered or unexported fields
}

EventHandler ... event handler to process events

func Init

func Init(nodeName string, stdOutToSocket bool, socketName string, processChannel chan EventChannel, closeCh chan bool,
	offsetMetric *prometheus.GaugeVec, clockMetric *prometheus.GaugeVec, clockClassMetric *prometheus.GaugeVec) *EventHandler

Init ... initialize event manager

func (*EventHandler) GetData

func (e *EventHandler) GetData(cfgName string, processName EventSource) *Data

GetData returns the queried Data and create one if not exist

func (*EventHandler) GetPTPState

func (e *EventHandler) GetPTPState(source EventSource, cfgName string) PTPState

GetPTPState ...

func (*EventHandler) MockEnable

func (e *EventHandler) MockEnable()

MockEnable ...

func (*EventHandler) ProcessEvents

func (e *EventHandler) ProcessEvents()

ProcessEvents ... process events to generate new events

func (*EventHandler) UpdateClockClass

func (e *EventHandler) UpdateClockClass(c net.Conn, clk ClockClassRequest)

UpdateClockClass ... update clock class

func (*EventHandler) UpdateClockStateMetrics

func (e *EventHandler) UpdateClockStateMetrics(state PTPState, process, iFace string)

UpdateClockStateMetrics ...

type EventSource

type EventSource string

EventSource ...

const (
	GNSS       EventSource = "gnss"
	DPLL       EventSource = "dpll"
	TS2PHC     EventSource = "ts2phc"
	PTP4l      EventSource = "ptp4l"
	PHC2SYS    EventSource = "phc2sys"
	PPS        EventSource = "1pps"
	SYNCE      EventSource = "synce4l"
	MONITORING EventSource = "monitoring"
)

type Notifier

type Notifier interface {
	Register(o *Subscriber)
	Unregister(o *Subscriber)
}

type PTPState

type PTPState string

PTPState ...

const (

	// PTP_FREERUN ...
	PTP_FREERUN PTPState = "s0"
	// PTP_HOLDOVER ...
	PTP_HOLDOVER PTPState = "s1"
	// PTP_LOCKED ...
	PTP_LOCKED PTPState = "s2"
	// PTP_UNKNOWN
	PTP_UNKNOWN PTPState = "-1"
	// PTP_NOTSET
	PTP_NOTSET PTPState = "-2"
)

Summary of States: State Description Action Taken Synchronization Status S0 Unlocked The clock is not synchronized to any source Free-running, no sync S1 Clock Step A large time step is applied to synchronize Large time offset detected, step adjustment made S2/s3 Locked The clock is synchronized and making small frequency adjustments to stay aligned Synchronized, making small adjustments

type StateNotifier

type StateNotifier struct {
	sync.Mutex
	Subscribers map[string]Subscriber
}
var (
	StateRegisterer *StateNotifier
)

func NewStateNotifier

func NewStateNotifier() *StateNotifier

func (*StateNotifier) Register

func (n *StateNotifier) Register(s Subscriber)

func (*StateNotifier) Unregister

func (n *StateNotifier) Unregister(s Subscriber)

type Subscriber

type Subscriber interface {
	ID() string
	// Monitor method to start ay monitoring process
	Monitor()
	// Notify to call when event occurs
	Notify(source EventSource, state PTPState)

	Topic() EventSource
}

type ValueType

type ValueType string

Jump to

Keyboard shortcuts

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