mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-06 09:16:24 +08:00
New inmem command queue (#736)
This commit is contained in:
@@ -303,19 +303,14 @@ func (db *Store) pollCommands(pubsub pubsub.PublishSubscriber) error {
|
||||
"request_type", ev.Payload.Command.RequestType,
|
||||
)
|
||||
|
||||
cq := new(QueueCommandQueued)
|
||||
cq.DeviceUDID = ev.DeviceUDID
|
||||
cq.CommandUUID = ev.Payload.CommandUUID
|
||||
|
||||
msgBytes, err := MarshalQueuedCommand(cq)
|
||||
err = PublishCommandQueued(pubsub, ev.DeviceUDID, ev.Payload.CommandUUID)
|
||||
if err != nil {
|
||||
level.Info(db.logger).Log("msg", "marshal queued command", "err", err)
|
||||
level.Info(db.logger).Log(
|
||||
"msg", "publish command to queued topic",
|
||||
"err", err,
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := pubsub.Publish(context.TODO(), CommandQueuedTopic, msgBytes); err != nil {
|
||||
level.Info(db.logger).Log("msg", "publish command to queued topic", "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -329,3 +324,16 @@ func isNotFound(err error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func PublishCommandQueued(pub pubsub.Publisher, udid, uuid string) error {
|
||||
cq := new(QueueCommandQueued)
|
||||
cq.DeviceUDID = udid
|
||||
cq.CommandUUID = uuid
|
||||
|
||||
msgBytes, err := MarshalQueuedCommand(cq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return pub.Publish(context.TODO(), CommandQueuedTopic, msgBytes)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user