-
Notifications
You must be signed in to change notification settings - Fork 21
Sync dependencies #889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync dependencies #889
Changes from all commits
6483ef5
1303d13
d2c3fab
d919eb9
e35b6da
c8125ec
67435d4
1170125
d58f086
179cd03
a030708
b2af3e0
a34313e
ace85d1
bfca74f
087bb6e
7a7b028
2356ffb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| package v1 | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "github.com/icinga/icinga-go-library/database" | ||
| "github.com/icinga/icinga-go-library/types" | ||
| ) | ||
|
|
||
| type Redundancygroup struct { | ||
| EntityWithoutChecksum `json:",inline"` | ||
| EnvironmentMeta `json:",inline"` | ||
| DisplayName string `json:"display_name"` | ||
| } | ||
|
|
||
| // TableName implements [database.TableNamer]. | ||
| func (r *Redundancygroup) TableName() string { | ||
| return "redundancy_group" | ||
| } | ||
|
|
||
| type RedundancygroupState struct { | ||
| EntityWithoutChecksum `json:",inline"` | ||
| EnvironmentMeta `json:",inline"` | ||
| RedundancyGroupId types.Binary `json:"redundancy_group_id"` | ||
| Failed types.Bool `json:"failed"` | ||
| IsReachable types.Bool `json:"is_reachable"` | ||
| LastStateChange types.UnixMilli `json:"last_state_change"` | ||
| } | ||
|
|
||
| // TableName implements [database.TableNamer]. | ||
| func (r *RedundancygroupState) TableName() string { | ||
| return "redundancy_group_state" | ||
| } | ||
|
|
||
| // Equal implements the [contracts.Equaler] interface. | ||
| func (r *RedundancygroupState) Equal(other any) bool { | ||
| if o, ok := other.(*RedundancygroupState); ok { | ||
| return bytes.Equal(r.Id, o.Id) && | ||
| bytes.Equal(r.EnvironmentId, o.EnvironmentId) && | ||
| bytes.Equal(r.RedundancyGroupId, o.RedundancyGroupId) && | ||
| r.Failed == o.Failed && | ||
| r.IsReachable == o.IsReachable && | ||
| r.LastStateChange.Time().Equal(o.LastStateChange.Time()) | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| type DependencyNode struct { | ||
| EntityWithoutChecksum `json:",inline"` | ||
| EnvironmentMeta `json:",inline"` | ||
| HostId types.Binary `json:"host_id"` | ||
| ServiceId types.Binary `json:"service_id"` | ||
| RedundancyGroupId types.Binary `json:"redundancy_group_id"` | ||
| } | ||
|
|
||
| type DependencyEdgeState struct { | ||
| EntityWithoutChecksum `json:",inline"` | ||
| EnvironmentMeta `json:",inline"` | ||
| Failed types.Bool `json:"failed"` | ||
| } | ||
|
|
||
| // Equal implements the [contracts.Equaler] interface. | ||
| func (es *DependencyEdgeState) Equal(other any) bool { | ||
| if other, ok := other.(*DependencyEdgeState); ok { | ||
| return bytes.Equal(es.Id, other.Id) && | ||
| bytes.Equal(es.EnvironmentId, other.EnvironmentId) && | ||
| es.Failed == other.Failed | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| type DependencyEdge struct { | ||
| EntityWithoutChecksum `json:",inline"` | ||
| EnvironmentMeta `json:",inline"` | ||
| FromNodeId types.Binary `json:"from_node_id"` | ||
| ToNodeId types.Binary `json:"to_node_id"` | ||
| DependencyEdgeStateId types.Binary `json:"dependency_edge_state_id"` | ||
| DisplayName string `json:"display_name"` | ||
| } | ||
|
|
||
| func NewRedundancygroup() database.Entity { | ||
| return &Redundancygroup{} | ||
| } | ||
|
|
||
| func NewRedundancygroupState() database.Entity { | ||
| return &RedundancygroupState{} | ||
| } | ||
|
|
||
| func NewDependencyNode() database.Entity { | ||
| return &DependencyNode{} | ||
| } | ||
|
|
||
| func NewDependencyEdgeState() database.Entity { | ||
| return &DependencyEdgeState{} | ||
| } | ||
|
|
||
| func NewDependencyEdge() database.Entity { | ||
| return &DependencyEdge{} | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -188,6 +188,8 @@ CREATE TABLE host ( | |||||||||||||||
| check_interval int unsigned NOT NULL, | ||||||||||||||||
| check_retry_interval int unsigned NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| total_children int unsigned DEFAULT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| active_checks_enabled enum('n', 'y') NOT NULL, | ||||||||||||||||
| passive_checks_enabled enum('n', 'y') NOT NULL, | ||||||||||||||||
| event_handler_enabled enum('n', 'y') NOT NULL, | ||||||||||||||||
|
|
@@ -313,6 +315,8 @@ CREATE TABLE host_state ( | |||||||||||||||
|
|
||||||||||||||||
| in_downtime enum('n', 'y') NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| affects_children enum('n', 'y') NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| execution_time int unsigned DEFAULT NULL, | ||||||||||||||||
| latency int unsigned DEFAULT NULL, | ||||||||||||||||
| check_timeout int unsigned DEFAULT NULL, | ||||||||||||||||
|
|
@@ -356,6 +360,8 @@ CREATE TABLE service ( | |||||||||||||||
| check_interval int unsigned NOT NULL, | ||||||||||||||||
| check_retry_interval int unsigned NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| total_children int unsigned DEFAULT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| active_checks_enabled enum('n', 'y') NOT NULL, | ||||||||||||||||
| passive_checks_enabled enum('n', 'y') NOT NULL, | ||||||||||||||||
| event_handler_enabled enum('n', 'y') NOT NULL, | ||||||||||||||||
|
|
@@ -482,6 +488,8 @@ CREATE TABLE service_state ( | |||||||||||||||
|
|
||||||||||||||||
| in_downtime enum('n', 'y') NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| affects_children enum('n', 'y') NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| execution_time int unsigned DEFAULT NULL, | ||||||||||||||||
| latency int unsigned DEFAULT NULL, | ||||||||||||||||
| check_timeout int unsigned DEFAULT NULL, | ||||||||||||||||
|
|
@@ -1334,6 +1342,63 @@ CREATE TABLE sla_history_downtime ( | |||||||||||||||
| INDEX idx_sla_history_downtime_env_downtime_end (environment_id, downtime_end) COMMENT 'Filter for sla history retention' | ||||||||||||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | ||||||||||||||||
|
|
||||||||||||||||
| CREATE TABLE redundancy_group ( | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rename this table to
Footnotes
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, it cannot! The Redis keys are generated dynamically based on the Go type name and that would result in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Otherwise" as in "if it actually was |
||||||||||||||||
| id binary(20) NOT NULL COMMENT 'sha1(name + all(member parent_name + timeperiod.name + states + ignore_soft_states))', | ||||||||||||||||
| environment_id binary(20) NOT NULL COMMENT 'environment.id', | ||||||||||||||||
| display_name text NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| CONSTRAINT pk_redundancy_group PRIMARY KEY (id) | ||||||||||||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | ||||||||||||||||
|
|
||||||||||||||||
| CREATE TABLE redundancy_group_state ( | ||||||||||||||||
| id binary(20) NOT NULL COMMENT 'redundancy_group.id', | ||||||||||||||||
| environment_id binary(20) NOT NULL COMMENT 'environment.id', | ||||||||||||||||
| redundancy_group_id binary(20) NOT NULL COMMENT 'redundancy_group.id', | ||||||||||||||||
| failed enum('n', 'y') NOT NULL, | ||||||||||||||||
| is_reachable enum('n', 'y') NOT NULL, | ||||||||||||||||
| last_state_change BIGINT UNSIGNED NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| CONSTRAINT pk_redundancy_group_state PRIMARY KEY (id), | ||||||||||||||||
|
|
||||||||||||||||
| UNIQUE INDEX idx_redundancy_group_state_redundancy_group_id (redundancy_group_id) | ||||||||||||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | ||||||||||||||||
|
|
||||||||||||||||
| CREATE TABLE dependency_node ( | ||||||||||||||||
| id binary(20) NOT NULL COMMENT 'host.id|service.id|redundancy_group.id', | ||||||||||||||||
| environment_id binary(20) NOT NULL COMMENT 'environment.id', | ||||||||||||||||
| host_id binary(20) DEFAULT NULL COMMENT 'host.id', | ||||||||||||||||
| service_id binary(20) DEFAULT NULL COMMENT 'service.id', | ||||||||||||||||
| redundancy_group_id binary(20) DEFAULT NULL COMMENT 'redundancy_group.id', | ||||||||||||||||
|
|
||||||||||||||||
| CONSTRAINT pk_dependency_node PRIMARY KEY (id), | ||||||||||||||||
|
|
||||||||||||||||
| UNIQUE INDEX idx_dependency_node_host_service_redundancygroup_id (host_id, service_id, redundancy_group_id), | ||||||||||||||||
| CONSTRAINT ck_dependency_node_either_checkable_or_redundancy_group_id CHECK ( | ||||||||||||||||
| IF(redundancy_group_id IS NULL, host_id IS NOT NULL, host_id IS NULL AND service_id IS NULL) = 1 | ||||||||||||||||
| ) | ||||||||||||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | ||||||||||||||||
|
|
||||||||||||||||
| CREATE TABLE dependency_edge_state ( | ||||||||||||||||
| id binary(20) NOT NULL COMMENT 'sha1([dependency_edge.from_node_id|parent_name + timeperiod.name + states + ignore_soft_states] + dependency_edge.to_node_id)', | ||||||||||||||||
| environment_id binary(20) NOT NULL COMMENT 'environment.id', | ||||||||||||||||
| failed enum('n', 'y') NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| CONSTRAINT pk_dependency_edge_state PRIMARY KEY (id) | ||||||||||||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | ||||||||||||||||
|
|
||||||||||||||||
| CREATE TABLE dependency_edge ( | ||||||||||||||||
| id binary(20) NOT NULL COMMENT 'sha1(from_node_id + to_node_id)', | ||||||||||||||||
| environment_id binary(20) NOT NULL COMMENT 'environment.id', | ||||||||||||||||
| from_node_id binary(20) NOT NULL COMMENT 'dependency_node.id', | ||||||||||||||||
| to_node_id binary(20) NOT NULL COMMENT 'dependency_node.id', | ||||||||||||||||
| dependency_edge_state_id binary(20) NOT NULL COMMENT 'dependency_edge_state.id', | ||||||||||||||||
| display_name text NOT NULL, | ||||||||||||||||
|
|
||||||||||||||||
| CONSTRAINT pk_dependency_edge PRIMARY KEY (id), | ||||||||||||||||
|
|
||||||||||||||||
| UNIQUE INDEX idx_dependency_edge_from_node_to_node_id (from_node_id, to_node_id) | ||||||||||||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | ||||||||||||||||
|
|
||||||||||||||||
| CREATE TABLE icingadb_schema ( | ||||||||||||||||
| id int unsigned NOT NULL AUTO_INCREMENT, | ||||||||||||||||
| version smallint unsigned NOT NULL, | ||||||||||||||||
|
|
@@ -1343,4 +1408,4 @@ CREATE TABLE icingadb_schema ( | |||||||||||||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | ||||||||||||||||
|
|
||||||||||||||||
| INSERT INTO icingadb_schema (version, timestamp) | ||||||||||||||||
| VALUES (6, UNIX_TIMESTAMP() * 1000); | ||||||||||||||||
| VALUES (7, UNIX_TIMESTAMP() * 1000); | ||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.