-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register tso/resource_manager services with ServiceRegistryEntry json…
… struct (#6171) close #5836 Register tso/resource_manager services with ServiceRegistryEntry json struct Signed-off-by: Bin Shi <binshi.bing@gmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
- Loading branch information
1 parent
bc12668
commit 266c021
Showing
5 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2023 TiKV Project Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package discovery | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/pingcap/log" | ||
"go.uber.org/zap" | ||
) | ||
|
||
// ServiceRegistryEntry is the registry entry of a service | ||
type ServiceRegistryEntry struct { | ||
ServiceAddr string `json:"serviceAddr"` | ||
} | ||
|
||
// Serialize this service registry entry | ||
func (e *ServiceRegistryEntry) Serialize() (serializedValue string, err error) { | ||
data, err := json.Marshal(e) | ||
if err != nil { | ||
log.Error("json marshal the service registry entry failed", zap.Error(err)) | ||
return "", err | ||
} | ||
return string(data), nil | ||
} | ||
|
||
// Deserialize the data to this service registry entry | ||
func (e *ServiceRegistryEntry) Deserialize(data []byte) error { | ||
if err := json.Unmarshal(data, e); err != nil { | ||
log.Error("json unmarshal the service registry entry failed", zap.Error(err)) | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters