diff --git a/pkg/monitor/monitor.go b/pkg/monitor/monitor.go index 9422cc4..d162510 100644 --- a/pkg/monitor/monitor.go +++ b/pkg/monitor/monitor.go @@ -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 diff --git a/pkg/monitor/register.go b/pkg/monitor/register.go index 08c6c75..dcc2902 100644 --- a/pkg/monitor/register.go +++ b/pkg/monitor/register.go @@ -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} } diff --git a/pkg/setup/service.go b/pkg/setup/service.go index 5352162..ed7626c 100644 --- a/pkg/setup/service.go +++ b/pkg/setup/service.go @@ -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} }