mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-11 20:45:32 +08:00
New inmem command queue (#736)
This commit is contained in:
@@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
@@ -25,6 +26,7 @@ import (
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub/inmem"
|
||||
"github.com/micromdm/micromdm/platform/queue"
|
||||
queueinmem "github.com/micromdm/micromdm/platform/queue/inmem"
|
||||
block "github.com/micromdm/micromdm/platform/remove"
|
||||
blockbuiltin "github.com/micromdm/micromdm/platform/remove/builtin"
|
||||
"github.com/micromdm/micromdm/workflow/webhook"
|
||||
@@ -63,6 +65,7 @@ type Server struct {
|
||||
ValidateSCEPIssuer bool
|
||||
ValidateSCEPExpiration bool
|
||||
UDIDCertAuthWarnOnly bool
|
||||
Queue string
|
||||
|
||||
APNSPushService apns.Service
|
||||
CommandService command.Service
|
||||
@@ -168,14 +171,26 @@ func (c *Server) setupCommandService() error {
|
||||
}
|
||||
|
||||
func (c *Server) setupCommandQueue(logger log.Logger) error {
|
||||
opts := []queue.Option{queue.WithLogger(logger)}
|
||||
if c.NoCmdHistory {
|
||||
opts = append(opts, queue.WithoutHistory())
|
||||
}
|
||||
q, err := queue.NewQueue(c.DB, c.PubClient, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
var q mdm.Queue
|
||||
switch c.Queue {
|
||||
case "inmem":
|
||||
q = queueinmem.New(c.PubClient, logger)
|
||||
case "builtin":
|
||||
opts := []queue.Option{queue.WithLogger(logger)}
|
||||
if c.NoCmdHistory {
|
||||
opts = append(opts, queue.WithoutHistory())
|
||||
}
|
||||
var err error
|
||||
q, err = queue.NewQueue(c.DB, c.PubClient, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "":
|
||||
return errors.New("empty command queue type")
|
||||
default:
|
||||
return fmt.Errorf("invalid command queue type: %s", c.Queue)
|
||||
}
|
||||
|
||||
devDB, err := devicebuiltin.NewDB(c.DB)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "new device db")
|
||||
|
||||
Reference in New Issue
Block a user