Skip to content

Commit

Permalink
*: fix typo (#8982)
Browse files Browse the repository at this point in the history
ref #4820

Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx authored Jan 8, 2025
1 parent 973234d commit adddd4e
Show file tree
Hide file tree
Showing 27 changed files with 203 additions and 203 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pd-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
- worker_id: 8
name: 'TSO Integration Test'
- worker_id: 9
name: 'MicroService Integration(!TSO)'
name: 'Microservice Integration(!TSO)'
- worker_id: 10
name: 'MicroService Integration(TSO)'
name: 'Microservice Integration(TSO)'
outputs:
job-total: 10
steps:
Expand Down
16 changes: 8 additions & 8 deletions client/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const (
Version = "/pd/api/v1/version"
operators = "/pd/api/v1/operators"
safepoint = "/pd/api/v1/gc/safepoint"
// Micro Service
microServicePrefix = "/pd/api/v2/ms"
// Microservice
microservicePrefix = "/pd/api/v2/ms"
// Keyspace
KeyspaceConfig = "/pd/api/v2/keyspaces/%s/config"
GetKeyspaceMetaByName = "/pd/api/v2/keyspaces/%s"
Expand Down Expand Up @@ -198,14 +198,14 @@ func PProfGoroutineWithDebugLevel(level int) string {
return fmt.Sprintf("%s?debug=%d", PProfGoroutine, level)
}

// MicroServiceMembers returns the path of PD HTTP API to get the members of microservice.
func MicroServiceMembers(service string) string {
return fmt.Sprintf("%s/members/%s", microServicePrefix, service)
// MicroserviceMembers returns the path of PD HTTP API to get the members of microservice.
func MicroserviceMembers(service string) string {
return fmt.Sprintf("%s/members/%s", microservicePrefix, service)
}

// MicroServicePrimary returns the path of PD HTTP API to get the primary of microservice.
func MicroServicePrimary(service string) string {
return fmt.Sprintf("%s/primary/%s", microServicePrefix, service)
// MicroservicePrimary returns the path of PD HTTP API to get the primary of microservice.
func MicroservicePrimary(service string) string {
return fmt.Sprintf("%s/primary/%s", microservicePrefix, service)
}

// GetUpdateKeyspaceConfigURL returns the path of PD HTTP API to update keyspace config.
Expand Down
24 changes: 12 additions & 12 deletions client/http/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ type Client interface {
GetPDVersion(context.Context) (string, error)
GetGCSafePoint(context.Context) (ListServiceGCSafepoint, error)
DeleteGCSafePoint(context.Context, string) (string, error)
/* Micro Service interfaces */
GetMicroServiceMembers(context.Context, string) ([]MicroServiceMember, error)
GetMicroServicePrimary(context.Context, string) (string, error)
/* Microservice interfaces */
GetMicroserviceMembers(context.Context, string) ([]MicroserviceMember, error)
GetMicroservicePrimary(context.Context, string) (string, error)
DeleteOperators(context.Context) error

/* Keyspace interface */
Expand Down Expand Up @@ -937,12 +937,12 @@ func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []uin
return resp.MinResolvedTS, resp.StoresMinResolvedTS, nil
}

// GetMicroServiceMembers gets the members of the microservice.
func (c *client) GetMicroServiceMembers(ctx context.Context, service string) ([]MicroServiceMember, error) {
var members []MicroServiceMember
// GetMicroserviceMembers gets the members of the microservice.
func (c *client) GetMicroserviceMembers(ctx context.Context, service string) ([]MicroserviceMember, error) {
var members []MicroserviceMember
err := c.request(ctx, newRequestInfo().
WithName(getMicroServiceMembersName).
WithURI(MicroServiceMembers(service)).
WithName(getMicroserviceMembersName).
WithURI(MicroserviceMembers(service)).
WithMethod(http.MethodGet).
WithResp(&members))
if err != nil {
Expand All @@ -951,12 +951,12 @@ func (c *client) GetMicroServiceMembers(ctx context.Context, service string) ([]
return members, nil
}

// GetMicroServicePrimary gets the primary of the microservice.
func (c *client) GetMicroServicePrimary(ctx context.Context, service string) (string, error) {
// GetMicroservicePrimary gets the primary of the microservice.
func (c *client) GetMicroservicePrimary(ctx context.Context, service string) (string, error) {
var primary string
err := c.request(ctx, newRequestInfo().
WithName(getMicroServicePrimaryName).
WithURI(MicroServicePrimary(service)).
WithName(getMicroservicePrimaryName).
WithURI(MicroservicePrimary(service)).
WithMethod(http.MethodGet).
WithResp(&primary))
return primary, err
Expand Down
4 changes: 2 additions & 2 deletions client/http/request_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const (
accelerateScheduleName = "AccelerateSchedule"
accelerateScheduleInBatchName = "AccelerateScheduleInBatch"
getMinResolvedTSByStoresIDsName = "GetMinResolvedTSByStoresIDs"
getMicroServiceMembersName = "GetMicroServiceMembers"
getMicroServicePrimaryName = "GetMicroServicePrimary"
getMicroserviceMembersName = "GetMicroserviceMembers"
getMicroservicePrimaryName = "GetMicroservicePrimary"
getPDVersionName = "GetPDVersion"
resetTSName = "ResetTS"
resetBaseAllocIDName = "ResetBaseAllocID"
Expand Down
4 changes: 2 additions & 2 deletions client/http/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ type MembersInfo struct {
EtcdLeader *pdpb.Member `json:"etcd_leader,omitempty"`
}

// MicroServiceMember is the member info of a micro service.
type MicroServiceMember struct {
// MicroserviceMember is the member info of a microservice.
type MicroserviceMember struct {
ServiceAddr string `json:"service-addr"`
Version string `json:"version"`
GitHash string `json:"git-hash"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/errs/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ var (
ErrInvalidGroup = errors.Normalize("invalid group settings, please check the group name, priority and the number of resources", errors.RFCCodeText("PD:resourcemanager:ErrInvalidGroup"))
)

// Micro service errors
// Microservice errors
var (
ErrNotFoundSchedulingPrimary = errors.Normalize("cannot find scheduling primary", errors.RFCCodeText("PD:mcs:ErrNotFoundSchedulingPrimary"))
ErrSchedulingServer = errors.Normalize("scheduling server meets %v", errors.RFCCodeText("PD:mcs:ErrSchedulingServer"))
Expand Down
2 changes: 1 addition & 1 deletion pkg/member/election_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// ElectionLeader defines the common interface of the leader, which is the pdpb.Member
// for in PD/PD service or the tsopb.Participant in the micro services.
// for in PD/PD service or the tsopb.Participant in the microservices.
type ElectionLeader interface {
// GetListenUrls returns the listen urls
GetListenUrls() []string
Expand Down
2 changes: 1 addition & 1 deletion pkg/schedule/placement/rule_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (m *RuleManager) Initialize(maxReplica int, locationLabels []string, isolat
if m.initialized {
return nil
}
// If RuleManager is initialized in micro service,
// If RuleManager is initialized in microservice,
// it will load from etcd watcher and do not modify rule directly.
if skipLoadRules {
m.ruleList = ruleList{
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/apiutil/apiutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ const (
XRealIPHeader = "X-Real-Ip"
// XCallerIDHeader is used to mark the caller ID.
XCallerIDHeader = "X-Caller-ID"
// XForbiddenForwardToMicroServiceHeader is used to indicate that forwarding the request to a microservice is explicitly disallowed.
XForbiddenForwardToMicroServiceHeader = "X-Forbidden-Forward-To-MicroService"
// XForwardedToMicroServiceHeader is used to signal that the request has already been forwarded to a microservice.
XForwardedToMicroServiceHeader = "X-Forwarded-To-MicroService"
// XForbiddenForwardToMicroserviceHeader is used to indicate that forwarding the request to a microservice is explicitly disallowed.
XForbiddenForwardToMicroserviceHeader = "X-Forbidden-Forward-To-Microservice"
// XForwardedToMicroserviceHeader is used to signal that the request has already been forwarded to a microservice.
XForwardedToMicroserviceHeader = "X-Forwarded-To-Microservice"

chunkSize = 4096
)
Expand Down
16 changes: 8 additions & 8 deletions pkg/utils/apiutil/serverapi/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ func MicroserviceRedirectRule(matchPath, targetPath, targetServiceName string,
}
}

func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, string) {
func (h *redirector) matchMicroserviceRedirectRules(r *http.Request) (bool, string) {
if !h.s.IsPDServiceMode() {
return false, ""
}
if len(h.microserviceRedirectRules) == 0 {
return false, ""
}
if r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) == "true" {
if r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) == "true" {
return false, ""
}
// Remove trailing '/' from the URL path
Expand Down Expand Up @@ -166,7 +166,7 @@ func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, stri
} else {
r.URL.Path = rule.targetPath
}
log.Debug("redirect to micro service", zap.String("path", r.URL.Path), zap.String("origin-path", origin),
log.Debug("redirect to microservice", zap.String("path", r.URL.Path), zap.String("origin-path", origin),
zap.String("target", addr), zap.String("method", r.Method))
return true, addr
}
Expand All @@ -175,15 +175,15 @@ func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, stri
}

func (h *redirector) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
redirectToMicroService, targetAddr := h.matchMicroServiceRedirectRules(r)
redirectToMicroservice, targetAddr := h.matchMicroserviceRedirectRules(r)
allowFollowerHandle := len(r.Header.Get(apiutil.PDAllowFollowerHandleHeader)) > 0

if h.s.IsClosed() {
http.Error(w, errs.ErrServerNotStarted.FastGenByArgs().Error(), http.StatusInternalServerError)
return
}

if (allowFollowerHandle || h.s.GetMember().IsLeader()) && !redirectToMicroService {
if (allowFollowerHandle || h.s.GetMember().IsLeader()) && !redirectToMicroservice {
next(w, r)
return
}
Expand All @@ -200,14 +200,14 @@ func (h *redirector) ServeHTTP(w http.ResponseWriter, r *http.Request, next http
}

var clientUrls []string
if redirectToMicroService {
if redirectToMicroservice {
if len(targetAddr) == 0 {
http.Error(w, errs.ErrRedirect.FastGenByArgs().Error(), http.StatusInternalServerError)
return
}
clientUrls = append(clientUrls, targetAddr)
// Add a header to the response, it is used to mark whether the request has been forwarded to the micro service.
w.Header().Add(apiutil.XForwardedToMicroServiceHeader, "true")
// Add a header to the response, it is used to mark whether the request has been forwarded to the microservice.
w.Header().Add(apiutil.XForwardedToMicroserviceHeader, "true")
} else if name := r.Header.Get(apiutil.PDRedirectorHeader); len(name) == 0 {
leader := h.waitForLeader(r)
// The leader has not been elected yet.
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/keypath/absolute_key_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
msTsoKespaceExpectedLeaderPathFormat = "/ms/%d/tso/keyspace_groups/election/%05d/primary/expected_primary" // "/ms/{cluster_id}/tso/keyspace_groups/election/{group_id}/primary"
)

// MsParam is the parameter of micro service.
// MsParam is the parameter of microservice.
type MsParam struct {
ServiceName string
GroupID uint32 // only used for tso keyspace group
Expand Down
14 changes: 7 additions & 7 deletions server/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func newConfHandler(svr *server.Server, rd *render.Render) *confHandler {
func (h *confHandler) GetConfig(w http.ResponseWriter, r *http.Request) {
cfg := h.svr.GetConfig()
if h.svr.IsServiceIndependent(constant.SchedulingServiceName) &&
r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) != "true" {
r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) != "true" {
schedulingServerConfig, err := h.getSchedulingServerConfig()
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
Expand Down Expand Up @@ -188,7 +188,7 @@ func (h *confHandler) updateConfig(cfg *config.Config, key string, value any) er
case "keyspace":
return h.updateKeyspaceConfig(cfg, kp[len(kp)-1], value)
case "micro-service":
return h.updateMicroServiceConfig(cfg, kp[len(kp)-1], value)
return h.updateMicroserviceConfig(cfg, kp[len(kp)-1], value)
}
return errors.Errorf("config prefix %s not found", kp[0])
}
Expand All @@ -209,8 +209,8 @@ func (h *confHandler) updateKeyspaceConfig(config *config.Config, key string, va
return err
}

func (h *confHandler) updateMicroServiceConfig(config *config.Config, key string, value any) error {
updated, found, err := jsonutil.AddKeyValue(&config.MicroService, key, value)
func (h *confHandler) updateMicroserviceConfig(config *config.Config, key string, value any) error {
updated, found, err := jsonutil.AddKeyValue(&config.Microservice, key, value)
if err != nil {
return err
}
Expand All @@ -220,7 +220,7 @@ func (h *confHandler) updateMicroServiceConfig(config *config.Config, key string
}

if updated {
err = h.svr.SetMicroServiceConfig(config.MicroService)
err = h.svr.SetMicroserviceConfig(config.Microservice)
}
return err
}
Expand Down Expand Up @@ -339,7 +339,7 @@ func getConfigMap(cfg map[string]any, key []string, value any) map[string]any {
// @Router /config/schedule [get]
func (h *confHandler) GetScheduleConfig(w http.ResponseWriter, r *http.Request) {
if h.svr.IsServiceIndependent(constant.SchedulingServiceName) &&
r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) != "true" {
r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) != "true" {
cfg, err := h.getSchedulingServerConfig()
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
Expand Down Expand Up @@ -412,7 +412,7 @@ func (h *confHandler) SetScheduleConfig(w http.ResponseWriter, r *http.Request)
// @Router /config/replicate [get]
func (h *confHandler) GetReplicationConfig(w http.ResponseWriter, r *http.Request) {
if h.svr.IsServiceIndependent(constant.SchedulingServiceName) &&
r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) != "true" {
r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) != "true" {
cfg, err := h.getSchedulingServerConfig()
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
Expand Down
8 changes: 4 additions & 4 deletions server/apiv2/handlers/micro_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/tikv/pd/server/apiv2/middlewares"
)

// RegisterMicroService registers microservice handler to the router.
func RegisterMicroService(r *gin.RouterGroup) {
// RegisterMicroservice registers microservice handler to the router.
func RegisterMicroservice(r *gin.RouterGroup) {
router := r.Group("ms")
router.GET("members/:service", GetMembers)
router.GET("primary/:service", GetPrimary)
Expand All @@ -40,7 +40,7 @@ func RegisterMicroService(r *gin.RouterGroup) {
func GetMembers(c *gin.Context) {
svr := c.MustGet(middlewares.ServerContextKey).(*server.Server)
if !svr.IsPDServiceMode() {
c.AbortWithStatusJSON(http.StatusNotFound, "not support micro service")
c.AbortWithStatusJSON(http.StatusNotFound, "not support microservice")
return
}

Expand All @@ -66,7 +66,7 @@ func GetMembers(c *gin.Context) {
func GetPrimary(c *gin.Context) {
svr := c.MustGet(middlewares.ServerContextKey).(*server.Server)
if !svr.IsPDServiceMode() {
c.AbortWithStatusJSON(http.StatusNotFound, "not support micro service")
c.AbortWithStatusJSON(http.StatusNotFound, "not support microservice")
return
}

Expand Down
2 changes: 1 addition & 1 deletion server/apiv2/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ func NewV2Handler(_ context.Context, svr *server.Server) (http.Handler, apiutil.
root.GET("ready", handlers.Ready)
handlers.RegisterKeyspace(root)
handlers.RegisterTSOKeyspaceGroup(root)
handlers.RegisterMicroService(root)
handlers.RegisterMicroservice(root)
return router, group, nil
}
4 changes: 2 additions & 2 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func (c *RaftCluster) Start(s Server, bootstrap bool) (err error) {
func (c *RaftCluster) checkSchedulingService() {
if c.isPDServiceMode {
servers, err := discovery.Discover(c.etcdClient, constant.SchedulingServiceName)
if c.opt.GetMicroServiceConfig().IsSchedulingFallbackEnabled() && (err != nil || len(servers) == 0) {
if c.opt.GetMicroserviceConfig().IsSchedulingFallbackEnabled() && (err != nil || len(servers) == 0) {
c.startSchedulingJobs(c, c.hbstreams)
c.UnsetServiceIndependent(constant.SchedulingServiceName)
} else {
Expand All @@ -426,7 +426,7 @@ func (c *RaftCluster) checkSchedulingService() {
// checkTSOService checks the TSO service.
func (c *RaftCluster) checkTSOService() {
if c.isPDServiceMode {
if c.opt.GetMicroServiceConfig().IsTSODynamicSwitchingEnabled() {
if c.opt.GetMicroserviceConfig().IsTSODynamicSwitchingEnabled() {
servers, err := discovery.Discover(c.etcdClient, constant.TSOServiceName)
if err != nil || len(servers) == 0 {
if err := c.startTSOJobsIfNeeded(); err != nil {
Expand Down
18 changes: 9 additions & 9 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ type Config struct {

Keyspace KeyspaceConfig `toml:"keyspace" json:"keyspace"`

MicroService MicroServiceConfig `toml:"micro-service" json:"micro-service"`
Microservice MicroserviceConfig `toml:"micro-service" json:"micro-service"`

Controller rm.ControllerConfig `toml:"controller" json:"controller"`
}
Expand Down Expand Up @@ -457,7 +457,7 @@ func (c *Config) Adjust(meta *toml.MetaData, reloading bool) error {

c.Keyspace.adjust(configMetaData.Child("keyspace"))

c.MicroService.adjust(configMetaData.Child("micro-service"))
c.Microservice.adjust(configMetaData.Child("micro-service"))

if err := c.Security.Encryption.Adjust(); err != nil {
return err
Expand Down Expand Up @@ -839,13 +839,13 @@ func (c *DRAutoSyncReplicationConfig) adjust(meta *configutil.ConfigMetaData) {
}
}

// MicroServiceConfig is the configuration for micro service.
type MicroServiceConfig struct {
// MicroserviceConfig is the configuration for microservice.
type MicroserviceConfig struct {
EnableSchedulingFallback bool `toml:"enable-scheduling-fallback" json:"enable-scheduling-fallback,string"`
EnableTSODynamicSwitching bool `toml:"enable-tso-dynamic-switching" json:"enable-tso-dynamic-switching,string"`
}

func (c *MicroServiceConfig) adjust(meta *configutil.ConfigMetaData) {
func (c *MicroserviceConfig) adjust(meta *configutil.ConfigMetaData) {
if !meta.IsDefined("enable-scheduling-fallback") {
c.EnableSchedulingFallback = defaultEnableSchedulingFallback
}
Expand All @@ -854,19 +854,19 @@ func (c *MicroServiceConfig) adjust(meta *configutil.ConfigMetaData) {
}
}

// Clone returns a copy of micro service config.
func (c *MicroServiceConfig) Clone() *MicroServiceConfig {
// Clone returns a copy of microservice config.
func (c *MicroserviceConfig) Clone() *MicroserviceConfig {
cfg := *c
return &cfg
}

// IsSchedulingFallbackEnabled returns whether to enable scheduling service fallback to PD service.
func (c *MicroServiceConfig) IsSchedulingFallbackEnabled() bool {
func (c *MicroserviceConfig) IsSchedulingFallbackEnabled() bool {
return c.EnableSchedulingFallback
}

// IsTSODynamicSwitchingEnabled returns whether to enable TSO dynamic switching.
func (c *MicroServiceConfig) IsTSODynamicSwitchingEnabled() bool {
func (c *MicroserviceConfig) IsTSODynamicSwitchingEnabled() bool {
return c.EnableTSODynamicSwitching
}

Expand Down
Loading

0 comments on commit adddd4e

Please sign in to comment.