Phước Trung преди 1 година
родител
ревизия
16571e1360
променени са 2 файла, в които са добавени 8 реда и са изтрити 8 реда
  1. 6 6
      processing_handler.go
  2. 2 2
      semaphore/semaphore.go

+ 6 - 6
processing_handler.go

@@ -208,7 +208,7 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
 	ctx := r.Context()
 
 	if queueSem != nil {
-		token, aquired := queueSem.TryAquire()
+		token, aquired := queueSem.TryAcquire()
 		if !aquired {
 			panic(ierrors.New(429, "Too many requests", "Too many requests"))
 		}
@@ -282,17 +282,17 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
 		}
 	}
 
-	// The heavy part start here, so we need to restrict workers number
+	// The heavy part start here, so we need to restrict worker number
 	var processingSemToken *semaphore.Token
 	func() {
 		defer metrics.StartQueueSegment(ctx)()
 
-		var aquired bool
-		processingSemToken, aquired = processingSem.Aquire(ctx)
-		if !aquired {
+		var acquired bool
+		processingSemToken, acquired = processingSem.Acquire(ctx)
+		if !acquired {
 			// We don't actually need to check timeout here,
 			// but it's an easy way to check if this is an actual timeout
-			// or the request was cancelled
+			// or the request was canceled
 			checkErr(ctx, "queue", router.CheckTimeout(ctx))
 		}
 	}()

+ 2 - 2
semaphore/semaphore.go

@@ -15,7 +15,7 @@ func New(n int) *Semaphore {
 	}
 }
 
-func (s *Semaphore) Aquire(ctx context.Context) (*Token, bool) {
+func (s *Semaphore) Acquire(ctx context.Context) (*Token, bool) {
 	select {
 	case s.sem <- struct{}{}:
 		return &Token{release: s.release}, true
@@ -24,7 +24,7 @@ func (s *Semaphore) Aquire(ctx context.Context) (*Token, bool) {
 	}
 }
 
-func (s *Semaphore) TryAquire() (*Token, bool) {
+func (s *Semaphore) TryAcquire() (*Token, bool) {
 	select {
 	case s.sem <- struct{}{}:
 		return &Token{release: s.release}, true