Make NameCiMeta an Initer

This commit is contained in:
Alexander A. Klimov 2021-03-10 16:19:49 +01:00
parent 4d24c97d90
commit ecf3dd74ae
5 changed files with 32 additions and 0 deletions

View file

@ -54,3 +54,9 @@ type EntityFactoryFunc func() Entity
type Waiter interface {
Wait() error // Wait waits for execution to complete.
}
// Initer implements the Init method,
// which initializes the object in addition to zeroing.
type Initer interface {
Init() // Init initializes the object.
}

View file

@ -1,6 +1,7 @@
package v1
import (
"github.com/icinga/icingadb/pkg/contracts"
"github.com/icinga/icingadb/pkg/types"
)
@ -38,3 +39,8 @@ type Checkable struct {
Zone string `json:"zone"`
ZoneId types.Binary `json:"zone_id"`
}
// Assert interface compliance.
var (
_ contracts.Initer = (*Checkable)(nil)
)

View file

@ -49,3 +49,8 @@ func NewHost() contracts.Entity {
return h
}
// Assert interface compliance.
var (
_ contracts.Initer = (*Host)(nil)
)

View file

@ -51,3 +51,13 @@ type NameCiMeta struct {
NameMeta
NameCi *string `json:"name_ci"`
}
// Init implements the contracts.Initer interface.
func (n *NameCiMeta) Init() {
n.NameCi = &n.Name
}
// Assert interface compliance.
var (
_ contracts.Initer = (*NameCiMeta)(nil)
)

View file

@ -17,3 +17,8 @@ func NewService() contracts.Entity {
return s
}
// Assert interface compliance.
var (
_ contracts.Initer = (*Service)(nil)
)