Skip to content

Commit 2681711

Browse files
committed
added mode to SC register request
1 parent 32dd330 commit 2681711

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

model/validate.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type RegisterRequest struct {
55
ID string `json:"id"` // This is the space cloud id
66
Key string `json:"key"`
77
Account string `json:"account"`
8+
Mode int `json:"mode"`
89
}
910

1011
// RegisterResponse is the response to the register request

utils/admin/admin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (m *Manager) SetOperationMode(op *config.OperationConfig) error {
4242

4343
if op.Mode > 0 {
4444
// Start the validation process for higher op modes
45-
if err := m.validator.startValidation(m.nodeID, op.Email, op.Key); err != nil {
45+
if err := m.validator.startValidation(m.nodeID, op.Email, op.Key, op.Mode); err != nil {
4646
return err
4747
}
4848
} else {

utils/admin/validate.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ func newValidator(cb func()) *validator {
2424
}
2525

2626
// Start starts the validation process
27-
func (v *validator) startValidation(id, account, key string) error {
27+
func (v *validator) startValidation(id, account, key string, mode int) error {
2828
// Set validation status to active
2929
v.lock.Lock()
3030
v.active = true
3131
v.lock.Unlock()
3232

33-
if err := v.registerSpaceCloud(id, account, key); err != nil {
33+
if err := v.registerSpaceCloud(id, account, key, mode); err != nil {
3434
return err
3535
}
3636

@@ -56,7 +56,7 @@ func (v *validator) startValidation(id, account, key string) error {
5656
return
5757
}
5858

59-
if err := v.registerSpaceCloud(id, account, key); err != nil {
59+
if err := v.registerSpaceCloud(id, account, key, mode); err != nil {
6060
log.Println("Validate: Error -", err)
6161
} else {
6262
timer = time.Now()

utils/admin/websocket.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func (v *validator) connect(url string) error {
3535
return nil
3636
}
3737

38-
func (v *validator) write(id, account, key string) error {
39-
req := &model.RegisterRequest{ID: id, Account: account, Key: key}
38+
func (v *validator) write(id, account, key string, mode int) error {
39+
req := &model.RegisterRequest{ID: id, Account: account, Key: key, Mode: mode}
4040
msg := &model.Message{Type: utils.TypeRegisterRequest, Data: req}
4141
return v.socket.WriteJSON(msg)
4242
}
@@ -69,13 +69,13 @@ func (v *validator) routineRead() error {
6969
}
7070
}
7171

72-
func (v *validator) registerSpaceCloud(id, account, secret string) error {
72+
func (v *validator) registerSpaceCloud(id, account, secret string, mode int) error {
7373
err := v.connect(url)
7474
if err != nil {
7575
return err
7676
}
7777

78-
err = v.write(id, account, secret)
78+
err = v.write(id, account, secret, mode)
7979
if err != nil {
8080
return err
8181
}

0 commit comments

Comments
 (0)