add module/broadcast_event method
This commit is contained in:
1 parent
96dee8dee3
commit
28aa3eae33
13 files changed
+105
-11
No files matched your search
+8
-2
@@ -15,12 +15,12 @@ const (
|
||||
ApplyCommandEvent = "CONFIG_CLUSTER:APPLY_COMMAND"
|
||||
CommandSizeBytes = 8
|
||||
|
||||
ClusterParam = "cluster"
|
||||
GETParam = "cluster"
|
||||
)
|
||||
|
||||
type Command uint64
|
||||
|
||||
// need: go get golang.org/x/tools/cmd/stringer
|
||||
// needed: go get golang.org/x/tools/cmd/stringer
|
||||
//go:generate stringer -type=Command -output const_string.go
|
||||
const (
|
||||
_ Command = iota
|
||||
@@ -39,6 +39,8 @@ const (
|
||||
|
||||
DeleteCommonConfigsCommand
|
||||
UpsertCommonConfigCommand
|
||||
|
||||
BroadcastEventCommand
|
||||
)
|
||||
|
||||
func PrepareUpdateBackendDeclarationCommand(backend structure.BackendDeclaration) []byte {
|
||||
@@ -85,6 +87,10 @@ func PrepareUpsertCommonConfigCommand(config UpsertCommonConfig) []byte {
|
||||
return prepareCommand(UpsertCommonConfigCommand, config)
|
||||
}
|
||||
|
||||
func PrepareBroadcastEventCommand(event BroadcastEvent) []byte {
|
||||
return prepareCommand(BroadcastEventCommand, event)
|
||||
}
|
||||
|
||||
func prepareCommand(command Command, payload interface{}) []byte {
|
||||
cmd := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(cmd, uint64(command))
|
||||
|
||||
@@ -19,11 +19,12 @@ func _() {
|
||||
_ = x[UpsertConfigCommand-9]
|
||||
_ = x[DeleteCommonConfigsCommand-10]
|
||||
_ = x[UpsertCommonConfigCommand-11]
|
||||
_ = x[BroadcastEventCommand-12]
|
||||
}
|
||||
|
||||
const _Command_name = "UpdateBackendDeclarationCommandDeleteBackendDeclarationCommandUpdateConfigSchemaCommandModuleConnectedCommandModuleDisconnectedCommandDeleteModulesCommandActivateConfigCommandDeleteConfigsCommandUpsertConfigCommandDeleteCommonConfigsCommandUpsertCommonConfigCommand"
|
||||
const _Command_name = "UpdateBackendDeclarationCommandDeleteBackendDeclarationCommandUpdateConfigSchemaCommandModuleConnectedCommandModuleDisconnectedCommandDeleteModulesCommandActivateConfigCommandDeleteConfigsCommandUpsertConfigCommandDeleteCommonConfigsCommandUpsertCommonConfigCommandBroadcastEventCommand"
|
||||
|
||||
var _Command_index = [...]uint16{0, 31, 62, 87, 109, 134, 154, 175, 195, 214, 240, 265}
|
||||
var _Command_index = [...]uint16{0, 31, 62, 87, 109, 134, 154, 175, 195, 214, 240, 265, 286}
|
||||
|
||||
func (i Command) String() string {
|
||||
i -= 1
|
||||
|
||||
+7
-1
@@ -3,9 +3,10 @@ package cluster
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"isp-config-service/entity"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ApplyLogResponse struct {
|
||||
@@ -45,6 +46,11 @@ type UpsertCommonConfig struct {
|
||||
Create bool
|
||||
}
|
||||
|
||||
type BroadcastEvent struct {
|
||||
Event string
|
||||
Payload json2.RawMessage
|
||||
}
|
||||
|
||||
type ResponseWithError struct {
|
||||
Response interface{}
|
||||
Error string
|
||||
|
||||
@@ -107,7 +107,7 @@ func getURL(address string) string {
|
||||
cfg := config.Get().(*conf.Configuration)
|
||||
|
||||
params := url.Values{}
|
||||
params.Add(ClusterParam, "true")
|
||||
params.Add(GETParam, "true")
|
||||
// TODO выпилить instance_uuid ?
|
||||
params.Add(utils.ModuleNameGetParamKey, cfg.ModuleName)
|
||||
params.Add(utils.InstanceUuidGetParamKey, "9d89354b-c728-4b48-b002-a7d3b229f151")
|
||||
|
||||
Reference in new issue
Block a user