MCPcopy
hub / github.com/spacecloud-io/space-cloud / New

Function New

gateway/managers/syncman/syncman.go:49–80  ·  view source on GitHub ↗

New creates a new instance of the sync manager

(nodeID, clusterID, storeType, runnerAddr string, adminMan AdminSyncmanInterface, integrationMan integrationInterface, ssl *config.SSL)

Source from the content-addressed store, hash-verified

47
48// New creates a new instance of the sync manager
49func New(nodeID, clusterID, storeType, runnerAddr string, adminMan AdminSyncmanInterface, integrationMan integrationInterface, ssl *config.SSL) (*Manager, error) {
50
51 // Create a new manager instance
52 m := &Manager{nodeID: nodeID, clusterID: clusterID, storeType: storeType, runnerAddr: runnerAddr, adminMan: adminMan, integrationMan: integrationMan}
53
54 // Initialise the consul client if enabled
55 var s Store
56 var err error
57 switch storeType {
58 case "local":
59 s, err = NewLocalStore(nodeID, ssl)
60 case "kube":
61 s, err = NewKubeStore(clusterID)
62 default:
63 return nil, helpers.Logger.LogError(helpers.GetRequestID(context.TODO()), fmt.Sprintf("Cannot initialize syncaman as invalid store type (%v) provided", storeType), nil, nil)
64 }
65
66 if err != nil {
67 return nil, err
68 }
69 m.store = s
70 m.store.Register()
71
72 pubsubClient, err := pubsub.New("license-manager", os.Getenv("REDIS_CONN"))
73 if err != nil {
74 return nil, helpers.Logger.LogError("syncman-new", "Unable to initialize pub sub client required for sync module, ensure that redis database is running", err, nil)
75 }
76 m.pubsubClient = pubsubClient
77 m.leader = leader.New(nodeID, pubsubClient)
78
79 return m, nil
80}
81
82// Start begins the sync manager operations
83func (s *Manager) Start(port int) error {

Callers

nothing calls this directly

Calls 3

NewLocalStoreFunction · 0.85
NewKubeStoreFunction · 0.70
RegisterMethod · 0.65

Tested by

no test coverage detected