initial import for nested configs
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
82824cdfcc
commit
4c32535bfa
@ -3,8 +3,10 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
openapi_v3 "github.com/google/gnostic/openapiv3"
|
openapi_v3 "github.com/google/gnostic/openapiv3"
|
||||||
@ -73,6 +75,27 @@ func main() {
|
|||||||
l.Fatal(ctx, "failed to open config", err)
|
l.Fatal(ctx, "failed to open config", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.App.ChecksDir != "" {
|
||||||
|
if !filepath.IsAbs(cfg.App.ChecksDir) {
|
||||||
|
dir, _ := os.Getwd()
|
||||||
|
cfg.App.ChecksDir = filepath.Clean(filepath.Join(dir, cfg.App.ChecksDir))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = filepath.WalkDir(cfg.App.ChecksDir, func(path string, info fs.DirEntry, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
// fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if info.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
l.Fatal(ctx, fmt.Sprintf("error loading config: %s", cfg.App.ChecksDir), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !cfg.App.MultiUser {
|
if !cfg.App.MultiUser {
|
||||||
m.Init(
|
m.Init(
|
||||||
meter.WriteFDMetrics(true),
|
meter.WriteFDMetrics(true),
|
||||||
@ -153,7 +176,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
clients["http"] = hcli
|
clients["http"] = hcli
|
||||||
|
|
||||||
for _, check := range cfg.Checks {
|
for _, check := range cfg.App.Checks {
|
||||||
l.Info(ctx, fmt.Sprintf("check %#+v", check))
|
l.Info(ctx, fmt.Sprintf("check %#+v", check))
|
||||||
if !check.Active {
|
if !check.Active {
|
||||||
continue
|
continue
|
||||||
|
@ -8,7 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
MultiUser bool `json:"multi_user,omitempty" yaml:"multi_user,omitempty"`
|
ChecksDir string `json:"checks_dir,omitempty" yaml:"checks_dir,omitempty"`
|
||||||
|
Checks []*CheckConfig `json:"checks,omitempty" yaml:"checks,omitempty"`
|
||||||
|
MultiUser bool `json:"multi_user,omitempty" yaml:"multi_user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MeterConfig struct {
|
type MeterConfig struct {
|
||||||
@ -17,9 +19,8 @@ type MeterConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
App *AppConfig `json:"app,omitempty" yaml:"app,omitempty"`
|
App *AppConfig `json:"app,omitempty" yaml:"app,omitempty"`
|
||||||
Meter *MeterConfig `json:"meter,omitempty" yaml:"meter,omitempty"`
|
Meter *MeterConfig `json:"meter,omitempty" yaml:"meter,omitempty"`
|
||||||
Checks []*CheckConfig `json:"checks,omitempty" yaml:"checks,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CheckConfig struct {
|
type CheckConfig struct {
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
package grpcconn
|
package grpcconn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/emicklei/proto"
|
|
||||||
"github.com/jhump/protoreflect/desc"
|
"github.com/jhump/protoreflect/desc"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var protoSets = map[string]*desc.FileDescriptor
|
var protoSets = map[string]*desc.FileDescriptor
|
||||||
|
Loading…
Reference in New Issue
Block a user