alby-hub/events/models.go
Roland 8ebb4ad716
fix: replace fatal logs with proper error handling (#707)
* fix: replace fatal logs with proper error handling

- fires nwc shutdown event synchronously
- requires at least one minute leeway for access token expiry

* chore: rename error

* fix: do not mask original reason for error

* fix: config error handling and error messages

* chore: rename
2024-09-25 17:31:05 +07:00

42 lines
1.1 KiB
Go

package events
import (
"context"
)
type EventSubscriber interface {
ConsumeEvent(ctx context.Context, event *Event, globalProperties map[string]interface{})
}
type EventPublisher interface {
RegisterSubscriber(eventListener EventSubscriber)
RemoveSubscriber(eventListener EventSubscriber)
Publish(event *Event)
PublishSync(event *Event)
SetGlobalProperty(key string, value interface{})
}
type Event struct {
Event string `json:"event"`
Properties interface{} `json:"properties,omitempty"`
}
type StaticChannelsBackupEvent struct {
NodeID string `json:"node_id"`
Channels []ChannelBackup `json:"channels"`
Monitors []EncodedChannelMonitorBackup `json:"monitors"`
}
type EncodedChannelMonitorBackup struct {
Key string `json:"key"`
Value string `json:"value"`
}
type ChannelBackup struct {
ChannelID string `json:"channel_id"`
PeerID string `json:"peer_id"`
PeerSocketAddress string `json:"peer_socket_address"`
ChannelSize uint64 `json:"channel_size"`
FundingTxID string `json:"funding_tx_id"`
FundingTxVout uint32 `json:"funding_tx_vout"`
}