Skip to content

Commit

Permalink
quota modify (#142)
Browse files Browse the repository at this point in the history
* find api dependency rule bug fix

* find api dependency rule bug fix

* quota apply bug fix

* http client bug fix
delete service bug fix
dependency optimize

* add upload schemas api

* upload schemas,add info in services.yaml

* delete service bug fix

* find dependency bug fix

* find dependency bug fix
governservice add some new response

* update gov service 's response

* update gov service response

* quota modify
  • Loading branch information
aseTo2016 authored and asifdxtreme committed Oct 27, 2017
1 parent 36c877a commit 32e7948
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
13 changes: 13 additions & 0 deletions server/service/event/instance_event_handler.go
Expand Up @@ -21,6 +21,8 @@ import (
nf "github.com/ServiceComb/service-center/server/service/notification"
serviceUtil "github.com/ServiceComb/service-center/server/service/util"
"golang.org/x/net/context"
"strings"
apt "github.com/ServiceComb/service-center/server/core"
)

type InstanceEventHandler struct {
Expand All @@ -40,6 +42,17 @@ func (h *InstanceEventHandler) OnEvent(evt *store.KvEvent) {
providerId, providerInstanceId, action)
return
}
if action == pb.EVT_DELETE {
spilted := strings.Split(tenantProject, "/")
if len(spilted) == 2 && apt.IsDefaultDomain(tenantProject) {
domainName := spilted[0]
projectName := spilted[1]
ctx := context.TODO()
ctx = context.WithValue(ctx, "tenant", domainName)
ctx = context.WithValue(ctx, "project", projectName)
serviceUtil.RemandInstanceQuota(ctx)
}
}

if nf.GetNotifyService().Closed() {
util.Logger().Warnf(nil, "caught instance %s/%s [%s] event, but notify service is closed",
Expand Down
2 changes: 0 additions & 2 deletions server/service/instances.go
Expand Up @@ -275,8 +275,6 @@ func (s *InstanceController) Unregister(ctx context.Context, in *pb.UnregisterIn
}, nil
}

serviceUtil.RemandInstanceQuota(ctx)

util.Logger().Infof("unregister instance successful isntance %s, operator %s.", instanceFlag, remoteIP)
return &pb.UnregisterInstanceResponse{
Response: pb.CreateResponse(pb.Response_SUCCESS, "Unregister service instance successfully."),
Expand Down
1 change: 0 additions & 1 deletion server/service/util/microservice_util.go
Expand Up @@ -232,7 +232,6 @@ func GetAllServiceUtil(ctx context.Context, opts ...registry.PluginOpOption) ([]

func RemandServiceQuota(ctx context.Context) {
quota.QuotaPlugins[quota.QuataType]().RemandQuotas(ctx, quota.MicroServiceQuotaType)
RemandInstanceQuota(ctx)
}

func RemandInstanceQuota(ctx context.Context) {
Expand Down

0 comments on commit 32e7948

Please sign in to comment.