Skip to content

Commit

Permalink
modify observability updateService processing
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyingjie committed Mar 23, 2021
1 parent 876c202 commit 63b5988
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions pkg/object/meshcontroller/worker/observability.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package worker
package main

import (
"fmt"
yaml "gopkg.in/yaml.v2"

"github.com/fatih/structs"
"github.com/megaease/easegateway/pkg/logger"
Expand Down Expand Up @@ -31,30 +32,24 @@ func NewObservabilityServer(serviceName string) *ObservabilityManager {
}
}

// UpdateObservability updates observability.
func (server *ObservabilityManager) UpdateObservability(serviceName string, newObservability *spec.Observability) error {
paramsMap := structs.Map(newObservability)
args := []interface{}{paramsMap}

logger.Infof("Update Service: %s Observability, new Observability is %s", serviceName, newObservability)
// UpdateService updates service.
func (server *ObservabilityManager) UpdateService(newService *spec.Service, version int64) error {

_, err := server.jolokiaClient.ExecuteMbeanOperation(easeAgentConfigManager, updateServiceOperation, args)
buff, err := yaml.Marshal(newService)
if err != nil {
return fmt.Errorf("update service: %s observability failed: %v", serviceName, err)
panic(fmt.Errorf("marsharl new Service %#v failed: %v", err))
}
m := make(map[string]string)
err = yaml.Unmarshal(buff, m)
if err != nil {
panic(fmt.Errorf("marsharl new Service %#v failed: %v", err))
}

return nil
}


// UpdateService updates service.
func (server *ObservabilityManager) UpdateService(newService *spec.Service, version int64) error {
paramsMap := structs.Map(newService)
args := []interface{}{paramsMap, version}
args := []interface{}{m, version}

logger.Infof("Update Service: %s Observability, new Service is %s", newService.Name, newService)

_, err := server.jolokiaClient.ExecuteMbeanOperation(easeAgentConfigManager, updateServiceOperation, args)
_, err = server.jolokiaClient.ExecuteMbeanOperation(easeAgentConfigManager, updateServiceOperation, args)
if err != nil {
return fmt.Errorf("UpdateService service: %s failed: %v", newService.Name, err)
}
Expand Down

0 comments on commit 63b5988

Please sign in to comment.