You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2017/12/27 10:16:50 UTC

[GitHub] little-cui closed pull request #231: SCB-128 Optimize lease.go

little-cui closed pull request #231: SCB-128 Optimize lease.go
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/231
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/core/backend/store/lease.go b/server/core/backend/store/lease.go
index 04a2ff9..2124b70 100644
--- a/server/core/backend/store/lease.go
+++ b/server/core/backend/store/lease.go
@@ -39,31 +39,31 @@ func (lat *LeaseAsyncTask) Key() string {
 	return lat.key
 }
 
-func (lat *LeaseAsyncTask) Do(ctx context.Context) (err error) {
+func (lat *LeaseAsyncTask) Do(ctx context.Context) error {
 	lat.StartTime = time.Now()
-	lat.TTL, err = backend.Registry().LeaseRenew(ctx, lat.LeaseID)
+	lat.TTL, lat.err = backend.Registry().LeaseRenew(ctx, lat.LeaseID)
 	lat.EndTime = time.Now()
-	if err == nil {
-		lat.err = err
+	if lat.err == nil {
 		util.LogNilOrWarnf(lat.CreateTime, "renew lease %d(rev: %s, run: %s), key %s",
 			lat.LeaseID,
 			lat.CreateTime.Format(TIME_FORMAT),
 			lat.StartTime.Format(TIME_FORMAT),
 			lat.Key())
-		return
+		return nil
 	}
 
-	util.Logger().Errorf(err, "[%s]renew lease %d failed(rev: %s, run: %s), key %s",
+	util.Logger().Errorf(lat.err, "[%s]renew lease %d failed(rev: %s, run: %s), key %s",
 		time.Now().Sub(lat.CreateTime),
 		lat.LeaseID,
 		lat.CreateTime.Format(TIME_FORMAT),
 		lat.StartTime.Format(TIME_FORMAT),
 		lat.Key())
-	if _, ok := err.(errorsEx.InternalError); !ok {
-		lat.err = err
-		return
+	if _, ok := lat.err.(errorsEx.InternalError); ok {
+		lat.err = nil
 	}
-	return nil
+
+	// lease not found.
+	return lat.err
 }
 
 func (lat *LeaseAsyncTask) Err() error {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services