refactor(setup-monitor): align service option names with RFC
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
44321aab25
commit
0779a7dbe5
3 changed files with 17 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
// service := monitor.New(monitor.Options{Interval: 30 * time.Second})
|
||||
// service := monitor.New(monitor.MonitorOptions{Interval: 30 * time.Second})
|
||||
// service.RegisterTools(server)
|
||||
package monitor
|
||||
|
||||
|
|
@ -110,14 +110,17 @@ func (m *Subsystem) HandleIPCEvents(_ *core.Core, msg core.Message) core.Result
|
|||
return core.Result{OK: true}
|
||||
}
|
||||
|
||||
// options := monitor.Options{Interval: 30 * time.Second}
|
||||
// options := monitor.MonitorOptions{Interval: 30 * time.Second}
|
||||
// service := monitor.New(options)
|
||||
type Options struct {
|
||||
type MonitorOptions struct {
|
||||
Interval time.Duration
|
||||
}
|
||||
|
||||
// service := monitor.New(monitor.Options{Interval: 30 * time.Second})
|
||||
func New(options ...Options) *Subsystem {
|
||||
// Options is kept as a compatibility alias for older callers.
|
||||
type Options = MonitorOptions
|
||||
|
||||
// service := monitor.New(monitor.MonitorOptions{Interval: 30 * time.Second})
|
||||
func New(options ...MonitorOptions) *Subsystem {
|
||||
interval := 2 * time.Minute
|
||||
if len(options) > 0 && options[0].Interval > 0 {
|
||||
interval = options[0].Interval
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
// service := c.Service("monitor")
|
||||
// core.Println(service.OK) // true
|
||||
func Register(c *core.Core) core.Result {
|
||||
service := New(Options{})
|
||||
service.ServiceRuntime = core.NewServiceRuntime(c, Options{})
|
||||
service := New(MonitorOptions{})
|
||||
service.ServiceRuntime = core.NewServiceRuntime(c, MonitorOptions{})
|
||||
return core.Result{Value: service, OK: true}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,20 +8,23 @@ import (
|
|||
core "dappco.re/go/core"
|
||||
)
|
||||
|
||||
// options := setup.RuntimeOptions{}
|
||||
type RuntimeOptions struct{}
|
||||
// options := setup.SetupOptions{}
|
||||
type SetupOptions struct{}
|
||||
|
||||
// RuntimeOptions is kept as a compatibility alias for older callers.
|
||||
type RuntimeOptions = SetupOptions
|
||||
|
||||
// c := core.New(core.WithService(setup.Register))
|
||||
// service := c.Service("setup")
|
||||
type Service struct {
|
||||
*core.ServiceRuntime[RuntimeOptions]
|
||||
*core.ServiceRuntime[SetupOptions]
|
||||
}
|
||||
|
||||
// c := core.New(core.WithService(setup.Register))
|
||||
// service := c.Service("setup")
|
||||
func Register(c *core.Core) core.Result {
|
||||
service := &Service{
|
||||
ServiceRuntime: core.NewServiceRuntime(c, RuntimeOptions{}),
|
||||
ServiceRuntime: core.NewServiceRuntime(c, SetupOptions{}),
|
||||
}
|
||||
return core.Result{Value: service, OK: true}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue