Major internal refactor to use an event bus to pass event/messages along. These changes are largely invisible user facing but sets up internal design for real time stats and information. - `--watch-config` logic refactored for events - remove multiple SSE api endpoints, replaced with /api/events - keep all functionality essentially the same - UI/backend sync is in near real time now
50 lines
916 B
Go
50 lines
916 B
Go
package proxy
|
|
|
|
// package level registry of the different event types
|
|
|
|
const ProcessStateChangeEventID = 0x01
|
|
const ChatCompletionStatsEventID = 0x02
|
|
const ConfigFileChangedEventID = 0x03
|
|
const LogDataEventID = 0x04
|
|
|
|
type ProcessStateChangeEvent struct {
|
|
ProcessName string
|
|
NewState ProcessState
|
|
OldState ProcessState
|
|
}
|
|
|
|
func (e ProcessStateChangeEvent) Type() uint32 {
|
|
return ProcessStateChangeEventID
|
|
}
|
|
|
|
type ChatCompletionStats struct {
|
|
TokensGenerated int
|
|
}
|
|
|
|
func (e ChatCompletionStats) Type() uint32 {
|
|
return ChatCompletionStatsEventID
|
|
}
|
|
|
|
type ReloadingState int
|
|
|
|
const (
|
|
ReloadingStateStart ReloadingState = iota
|
|
ReloadingStateEnd
|
|
)
|
|
|
|
type ConfigFileChangedEvent struct {
|
|
ReloadingState ReloadingState
|
|
}
|
|
|
|
func (e ConfigFileChangedEvent) Type() uint32 {
|
|
return ConfigFileChangedEventID
|
|
}
|
|
|
|
type LogDataEvent struct {
|
|
Data []byte
|
|
}
|
|
|
|
func (e LogDataEvent) Type() uint32 {
|
|
return LogDataEventID
|
|
}
|