You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/07/29 12:55:08 UTC

[incubator-apisix] branch master updated: plugin(batch): change processor name and error return type fix (#1927)

This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 0ad813e  plugin(batch): change processor name and error return type fix (#1927)
0ad813e is described below

commit 0ad813eb51a8c132c66a212ab43e963c3dad576f
Author: Nirojan Selvanathan <ss...@gmail.com>
AuthorDate: Wed Jul 29 14:54:58 2020 +0200

    plugin(batch): change processor name and error return type fix (#1927)
    
    Fix #1522
    Fix #1521
---
 apisix/utils/batch-processor.lua | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/apisix/utils/batch-processor.lua b/apisix/utils/batch-processor.lua
index 20e8353..18919c3 100644
--- a/apisix/utils/batch-processor.lua
+++ b/apisix/utils/batch-processor.lua
@@ -21,9 +21,9 @@ local ipairs = ipairs
 local table = table
 local now = ngx.now
 local type = type
-local Batch_Processor = {}
-local Batch_Processor_mt = {
-    __index = Batch_Processor
+local batch_processor = {}
+local batch_processor_mt = {
+    __index = batch_processor
 }
 local execute_func
 local create_buffer_timer
@@ -109,17 +109,17 @@ function create_buffer_timer(self)
 end
 
 
-function Batch_Processor:new(func, config)
+function batch_processor:new(func, config)
     local ok, err = core.schema.check(schema, config)
     if not ok then
-        return err
+        return nil, err
     end
 
     if not(type(func) == "function") then
         return nil, "Invalid argument, arg #1 must be a function"
     end
 
-    local batch_processor = {
+    local processor = {
         func = func,
         buffer_duration = config.buffer_duration,
         inactive_timeout = config.inactive_timeout,
@@ -134,11 +134,11 @@ function Batch_Processor:new(func, config)
         last_entry_t = 0
     }
 
-    return setmetatable(batch_processor, Batch_Processor_mt)
+    return setmetatable(processor, batch_processor_mt)
 end
 
 
-function Batch_Processor:push(entry)
+function batch_processor:push(entry)
     -- if the batch size is one then immediately send for processing
     if self.batch_max_size == 1 then
         local batch = { entries = { entry }, retry_count = 0 }
@@ -166,7 +166,7 @@ function Batch_Processor:push(entry)
 end
 
 
-function Batch_Processor:process_buffer()
+function batch_processor:process_buffer()
     -- If entries are present in the buffer move the entries to processing
     if #self.entry_buffer.entries > 0 then
         core.log.debug("tranferring buffer entries to processing pipe line, ",
@@ -182,4 +182,4 @@ function Batch_Processor:process_buffer()
 end
 
 
-return Batch_Processor
+return batch_processor