mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 14:50:55 +01:00
metrics infrastructure (#128)
This commit is contained in:
parent
022084ec88
commit
f2e887f70b
29
controller/metrics/agent.go
Normal file
29
controller/metrics/agent.go
Normal file
@ -0,0 +1,29 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Run(cfg *Config) error {
|
||||
logrus.Info("starting")
|
||||
defer logrus.Warn("stopping")
|
||||
|
||||
if cfg.Source == nil {
|
||||
return errors.New("no 'source' configured; exiting")
|
||||
}
|
||||
|
||||
src, ok := cfg.Source.(Source)
|
||||
if !ok {
|
||||
return errors.New("invalid 'source'; exiting")
|
||||
}
|
||||
|
||||
srcJoin, err := src.Start()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error starting source")
|
||||
}
|
||||
|
||||
<-srcJoin
|
||||
|
||||
return nil
|
||||
}
|
10
controller/metrics/cf.go
Normal file
10
controller/metrics/cf.go
Normal file
@ -0,0 +1,10 @@
|
||||
package metrics
|
||||
|
||||
import "github.com/michaelquigley/cf"
|
||||
|
||||
func GetCfOptions() *cf.Options {
|
||||
opts := cf.DefaultOptions()
|
||||
opts.AddFlexibleSetter("file", loadFileSourceConfig)
|
||||
opts.AddFlexibleSetter("websocket", loadWebsocketSourceConfig)
|
||||
return opts
|
||||
}
|
5
controller/metrics/config.go
Normal file
5
controller/metrics/config.go
Normal file
@ -0,0 +1,5 @@
|
||||
package metrics
|
||||
|
||||
type Config struct {
|
||||
Source interface{}
|
||||
}
|
17
controller/metrics/fileSource.go
Normal file
17
controller/metrics/fileSource.go
Normal file
@ -0,0 +1,17 @@
|
||||
package metrics
|
||||
|
||||
import "github.com/michaelquigley/cf"
|
||||
|
||||
type FileSourceConfig struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
func loadFileSourceConfig(v interface{}, opts *cf.Options) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type fileSource struct{}
|
||||
|
||||
func (s *fileSource) Start() (chan struct{}, error) {
|
||||
return nil, nil
|
||||
}
|
10
controller/metrics/model.go
Normal file
10
controller/metrics/model.go
Normal file
@ -0,0 +1,10 @@
|
||||
package metrics
|
||||
|
||||
type Source interface {
|
||||
Start() (chan struct{}, error)
|
||||
Stop()
|
||||
}
|
||||
|
||||
type Ingester interface {
|
||||
Ingest(msg map[string]interface{})
|
||||
}
|
17
controller/metrics/websocketSource.go
Normal file
17
controller/metrics/websocketSource.go
Normal file
@ -0,0 +1,17 @@
|
||||
package metrics
|
||||
|
||||
import "github.com/michaelquigley/cf"
|
||||
|
||||
type WebsocketSourceConfig struct {
|
||||
WebsocketEndpoint string
|
||||
}
|
||||
|
||||
func loadWebsocketSourceConfig(v interface{}, opts *cf.Options) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type websocketSource struct{}
|
||||
|
||||
func (s *websocketSource) Start() (chan struct{}, error) {
|
||||
return nil, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user