mirror of
https://github.com/datarhei/core.git
synced 2025-09-27 04:16:25 +08:00
Add RegistryReader interface for read-only registry
This commit is contained in:
@@ -13,11 +13,11 @@ import (
|
|||||||
|
|
||||||
// The SessionHandler type provides handlers to retrieve session information
|
// The SessionHandler type provides handlers to retrieve session information
|
||||||
type SessionHandler struct {
|
type SessionHandler struct {
|
||||||
registry session.Registry
|
registry session.RegistryReader
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSession returns a new Session type. You have to provide a session registry.
|
// NewSession returns a new Session type. You have to provide a session registry.
|
||||||
func NewSession(registry session.Registry) *SessionHandler {
|
func NewSession(registry session.RegistryReader) *SessionHandler {
|
||||||
return &SessionHandler{
|
return &SessionHandler{
|
||||||
registry: registry,
|
registry: registry,
|
||||||
}
|
}
|
||||||
|
@@ -13,13 +13,13 @@ import (
|
|||||||
|
|
||||||
type WidgetConfig struct {
|
type WidgetConfig struct {
|
||||||
Restream restream.Restreamer
|
Restream restream.Restreamer
|
||||||
Registry session.Registry
|
Registry session.RegistryReader
|
||||||
}
|
}
|
||||||
|
|
||||||
// The WidgetHandler type provides handlers for the widget API
|
// The WidgetHandler type provides handlers for the widget API
|
||||||
type WidgetHandler struct {
|
type WidgetHandler struct {
|
||||||
restream restream.Restreamer
|
restream restream.Restreamer
|
||||||
registry session.Registry
|
registry session.RegistryReader
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWidget return a new Widget type
|
// NewWidget return a new Widget type
|
||||||
|
@@ -89,7 +89,7 @@ type Config struct {
|
|||||||
JWT jwt.JWT
|
JWT jwt.JWT
|
||||||
Config config.Store
|
Config config.Store
|
||||||
Cache cache.Cacher
|
Cache cache.Cacher
|
||||||
Sessions session.Registry
|
Sessions session.RegistryReader
|
||||||
Router router.Router
|
Router router.Router
|
||||||
ReadOnly bool
|
ReadOnly bool
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
type sessionCollector struct {
|
type sessionCollector struct {
|
||||||
prefix string
|
prefix string
|
||||||
r session.Registry
|
r session.RegistryReader
|
||||||
collectors []string
|
collectors []string
|
||||||
totalDescr *metric.Description
|
totalDescr *metric.Description
|
||||||
limitDescr *metric.Description
|
limitDescr *metric.Description
|
||||||
@@ -20,7 +20,7 @@ type sessionCollector struct {
|
|||||||
maxRxBitrateDescr *metric.Description
|
maxRxBitrateDescr *metric.Description
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSessionCollector(r session.Registry, collectors []string) metric.Collector {
|
func NewSessionCollector(r session.RegistryReader, collectors []string) metric.Collector {
|
||||||
c := &sessionCollector{
|
c := &sessionCollector{
|
||||||
prefix: "session",
|
prefix: "session",
|
||||||
r: r,
|
r: r,
|
||||||
|
@@ -22,6 +22,20 @@ type Config struct {
|
|||||||
Logger log.Logger
|
Logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RegistryReader interface {
|
||||||
|
// Collectors returns an array of all registered IDs
|
||||||
|
Collectors() []string
|
||||||
|
|
||||||
|
// Collector returns the collector with the ID, or nil if the ID is not registered
|
||||||
|
Collector(id string) Collector
|
||||||
|
|
||||||
|
// Summary returns the summary from a collector with the ID, or an empty summary if the ID is not registered
|
||||||
|
Summary(id string) Summary
|
||||||
|
|
||||||
|
// Active returns the active sessions from a collector with the ID, or an empty list if the ID is not registered
|
||||||
|
Active(id string) []Session
|
||||||
|
}
|
||||||
|
|
||||||
// The Registry interface
|
// The Registry interface
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// Register returns a new collector from conf and registers it under the id and error is nil. In case of error
|
// Register returns a new collector from conf and registers it under the id and error is nil. In case of error
|
||||||
@@ -34,17 +48,7 @@ type Registry interface {
|
|||||||
// UnregisterAll unregisters al registered collectors
|
// UnregisterAll unregisters al registered collectors
|
||||||
UnregisterAll()
|
UnregisterAll()
|
||||||
|
|
||||||
// Collectors returns an array of all registered IDs
|
RegistryReader
|
||||||
Collectors() []string
|
|
||||||
|
|
||||||
// Collector returns the collector with the ID, or nil if the ID is not registered
|
|
||||||
Collector(id string) Collector
|
|
||||||
|
|
||||||
// Summary returns the summary from a collector with the ID, or an empty summary if the ID is not registered
|
|
||||||
Summary(id string) Summary
|
|
||||||
|
|
||||||
// Active returns the active sessions from a collector with the ID, or an empty list if the ID is not registered
|
|
||||||
Active(id string) []Session
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type registry struct {
|
type registry struct {
|
||||||
|
Reference in New Issue
Block a user