mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-09 02:55:59 +08:00
Closes #302 This package still needs a lot of work, but I feel like this is a good stopping point. In a follow up, I plan on writing some tests, and refactoring some of the ways the sync.Watcher goroutines are managed.
41 lines
857 B
Go
41 lines
857 B
Go
package sync
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/go-kit/kit/endpoint"
|
|
)
|
|
|
|
func (s *DEPSyncService) SyncNow(_ context.Context) error {
|
|
s.syncer.SyncNow()
|
|
return nil
|
|
}
|
|
|
|
type syncNowResponse struct{}
|
|
type syncNowRequest struct{}
|
|
|
|
func MakeSyncNowEndpoint(s Service) endpoint.Endpoint {
|
|
return func(ctx context.Context, _ interface{}) (interface{}, error) {
|
|
s.SyncNow(ctx)
|
|
return syncNowResponse{}, nil
|
|
}
|
|
}
|
|
|
|
func decodeEmptyRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func encodeEmptyResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {
|
|
return nil
|
|
}
|
|
|
|
func decodeEmptyResponse(ctx context.Context, r *http.Response) (interface{}, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (e Endpoints) SyncNow(ctx context.Context) error {
|
|
_, err := e.SyncNowEndpoint(ctx, nil)
|
|
return err
|
|
}
|