* Execute the pending configuration item. * * This function processes the pending configuration item by performing the necessary Redis operations based * on the dirty bits set for the associated configuration object. It handles configuration deletions, updates, * and state updates for checkable objects. * * @param item The queue item to process. */
| 122 | * @param item The queue item to process. |
| 123 | */ |
| 124 | void IcingaDB::ProcessQueueItem(const icingadb::task_queue::PendingConfigItem& item) |
| 125 | { |
| 126 | namespace queue = icingadb::task_queue; |
| 127 | |
| 128 | ObjectLock olock(item.Object); |
| 129 | |
| 130 | if (item.DirtyBits & queue::ConfigDelete) { |
| 131 | auto redisKeyPair = GetSyncableTypeRedisKeys(item.Object->GetReflectionType()); |
| 132 | m_RconWorker->FireAndForgetQueries( |
| 133 | { |
| 134 | {"HDEL", redisKeyPair.ObjectKey, GetObjectIdentifier(item.Object)}, |
| 135 | {"HDEL", redisKeyPair.ChecksumKey, GetObjectIdentifier(item.Object)}, |
| 136 | { |
| 137 | "XADD", |
| 138 | "icinga:runtime", |
| 139 | "MAXLEN", |
| 140 | "~", |
| 141 | "1000000", |
| 142 | "*", |
| 143 | "redis_key", |
| 144 | redisKeyPair.ObjectKey, |
| 145 | "id", |
| 146 | GetObjectIdentifier(item.Object), |
| 147 | "runtime_type", |
| 148 | "delete" |
| 149 | } |
| 150 | } |
| 151 | ); |
| 152 | } |
| 153 | |
| 154 | if (item.DirtyBits & queue::ConfigUpdate) { |
| 155 | std::map<RedisConnection::QueryArg, RedisConnection::Query> hMSets; |
| 156 | std::vector<Dictionary::Ptr> runtimeUpdates; |
| 157 | CreateConfigUpdate(item.Object, GetSyncableTypeRedisKeys(item.Object->GetReflectionType()), hMSets, runtimeUpdates, true); |
| 158 | ExecuteRedisTransaction(m_RconWorker, hMSets, runtimeUpdates); |
| 159 | } |
| 160 | |
| 161 | if (auto checkable = dynamic_pointer_cast<Checkable>(item.Object); checkable) { |
| 162 | if (item.DirtyBits & queue::FullState) { |
| 163 | UpdateState(checkable, item.DirtyBits); |
| 164 | } |
| 165 | if (item.DirtyBits & queue::NextUpdate) { |
| 166 | std::string_view redisKey; |
| 167 | if (dynamic_pointer_cast<Service>(checkable)) { |
| 168 | redisKey = CONFIG_REDIS_KEY_PREFIX "nextupdate:service"; |
| 169 | } else { |
| 170 | redisKey = CONFIG_REDIS_KEY_PREFIX "nextupdate:host"; |
| 171 | } |
| 172 | auto ID = GetObjectIdentifier(checkable); |
| 173 | if (checkable->GetEnableActiveChecks() && !checkable->GetExtension("ConfigObjectDeleted")) { |
| 174 | m_RconWorker->FireAndForgetQuery({"ZADD", redisKey, Convert::ToString(checkable->GetNextUpdate()), ID}); |
| 175 | } else { |
| 176 | m_RconWorker->FireAndForgetQuery({"ZREM", redisKey, ID}); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 |
nothing calls this directly
no test coverage detected