mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Introduce meta types
This commit is contained in:
parent
bb9a2b0251
commit
34603b5e1d
2 changed files with 77 additions and 0 deletions
24
pkg/icingadb/v1/entity.go
Normal file
24
pkg/icingadb/v1/entity.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package v1
|
||||
|
||||
import "github.com/icinga/icingadb/pkg/contracts"
|
||||
|
||||
// EntityWithoutChecksum represents entities without a checksum.
|
||||
type EntityWithoutChecksum struct {
|
||||
IdMeta `json:",inline"`
|
||||
}
|
||||
|
||||
// Fingerprint implements the contracts.Fingerprinter interface.
|
||||
func (e EntityWithoutChecksum) Fingerprint() contracts.Fingerprinter {
|
||||
return e
|
||||
}
|
||||
|
||||
// EntityWithChecksum represents entities with a checksum.
|
||||
type EntityWithChecksum struct {
|
||||
EntityWithoutChecksum
|
||||
ChecksumMeta `json:",inline"`
|
||||
}
|
||||
|
||||
// Fingerprint implements the contracts.Fingerprinter interface.
|
||||
func (e EntityWithChecksum) Fingerprint() contracts.Fingerprinter {
|
||||
return e
|
||||
}
|
||||
53
pkg/icingadb/v1/meta.go
Normal file
53
pkg/icingadb/v1/meta.go
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"github.com/icinga/icingadb/pkg/contracts"
|
||||
"github.com/icinga/icingadb/pkg/types"
|
||||
)
|
||||
|
||||
// ChecksumMeta is embedded by every type with a checksum.
|
||||
type ChecksumMeta struct {
|
||||
PropertiesChecksum types.Binary `json:"checksum"`
|
||||
}
|
||||
|
||||
// Checksum implements part of the contracts.Checksumer interface.
|
||||
func (m ChecksumMeta) Checksum() contracts.Checksum {
|
||||
return m.PropertiesChecksum
|
||||
}
|
||||
|
||||
// SetChecksum implements part of the contracts.Checksumer interface.
|
||||
func (m *ChecksumMeta) SetChecksum(checksum contracts.Checksum) {
|
||||
m.PropertiesChecksum = checksum.(types.Binary)
|
||||
}
|
||||
|
||||
// EnvironmentMeta is embedded by every type which belongs to an environment.
|
||||
type EnvironmentMeta struct {
|
||||
EnvironmentId types.Binary `json:"environment_id"`
|
||||
}
|
||||
|
||||
// IdMeta is embedded by every type Icinga DB should synchronize.
|
||||
type IdMeta struct {
|
||||
Id types.Binary `json:"id"`
|
||||
}
|
||||
|
||||
// ID implements part of the contracts.IDer interface.
|
||||
func (m IdMeta) ID() contracts.ID {
|
||||
return m.Id
|
||||
}
|
||||
|
||||
// SetID implements part of the contracts.IDer interface.
|
||||
func (m *IdMeta) SetID(id contracts.ID) {
|
||||
m.Id = id.(types.Binary)
|
||||
}
|
||||
|
||||
// NameMeta is embedded by every type with a name.
|
||||
type NameMeta struct {
|
||||
Name string `json:"name"`
|
||||
NameChecksum types.Binary `json:"name_checksum"`
|
||||
}
|
||||
|
||||
// NameCiMeta is embedded by every type with a case insensitive name.
|
||||
type NameCiMeta struct {
|
||||
NameMeta
|
||||
NameCi *string `json:"name_ci"`
|
||||
}
|
||||
Loading…
Reference in a new issue