{"id":20743088,"url":"https://github.com/aimingoo/harpseal","last_synced_at":"2026-04-19T08:33:22.008Z","repository":{"id":89039338,"uuid":"45772144","full_name":"aimingoo/harpseal","owner":"aimingoo","description":"Parallel Exchangeable Distribution Task for Lua.","archived":false,"fork":false,"pushed_at":"2015-12-03T22:10:48.000Z","size":73,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T12:38:19.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aimingoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-08T08:05:07.000Z","updated_at":"2020-03-30T13:26:51.000Z","dependencies_parsed_at":"2023-03-19T01:56:45.859Z","dependency_job_id":null,"html_url":"https://github.com/aimingoo/harpseal","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aimingoo/harpseal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimingoo%2Fharpseal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimingoo%2Fharpseal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimingoo%2Fharpseal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimingoo%2Fharpseal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aimingoo","download_url":"https://codeload.github.com/aimingoo/harpseal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aimingoo%2Fharpseal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32000351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T07:09:02.382Z","updated_at":"2026-04-19T08:33:21.990Z","avatar_url":"https://github.com/aimingoo.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# harpseal\n\nharpseal is implement of PEDT - Parallel Exchangeable Distribution Task specifications for lua.\n\nPEDT v1.1 specifications supported.\n\n#### Table of Contents\n\n* [install](#install)\n* [import and usage](#import-and-usage)\n* [options](#options)\n* [interfaces](#interfaces)\n  * [pedt:run](#pedtrun)\n  * [pedt:map](#pedtmap)\n  * [pedt:execute_task](#pedtexecute_task)\n  * [pedt:register_task](#pedtregister_task)\n  * [pedt:require](#pedtrequire)\n  * [pedt:upgrade](#pedtupgrade)\n  * [pedt.LOGGER](#pedtlogger)\n  * [pedt.TASK_XXX](#pedttask_xxx)\n  * [pedt.version](#pedtversion)\n* [helpers](#helpers)\n  * [Harpseal.infra.taskhelper](#harpsealinfrataskhelper)\n  * [Harpseal.infra.httphelper](#harpsealinfrahttphelper)\n  * [Harpseal.tools.taskloader](#harpsealtoolstaskloader)\n  * [pedt.lua utility](#pedtlua-utility)\n    * [action: help](#action-help)\n    * [action: add](#action-add)\n    * [action: run](#action-run)\n    * [action: methods ](#action-methods)\n* [testcase](#testcase)\n* [history](#history)\n\n# install\n\n\u003e git clone https://github.com/aimingoo/harpseal\n\nor\n\n\u003e luarocks install harpseal\n\n# import and usage\n\n``` lua\n-- require when installed by luarocks\nlocal Harpseal = require('harpseal');\n\n-- or hard load from lua_path/directory\n-- local Harpseal = require('lib.Distributed');\n\nlocal options = {};\nlocal pedt = Harpseal:new(options);\n\npedt:run(..)\n\t:andThen(function(result){\n\t\t..\n\t})\n```\n\n# options\n\nthe full options schema:\n\n``` lua\noptions = {\n    distributed_request = function(arrResult) .. end, -- a http client implement\n    default_rejected: function(message) { .. }, -- a default rejected inject\n    system_route = { .. }, -- any key/value pairs\n\ttask_register_center = {\n\t\tdownload_task = function(taskId) .. end, -- PEDT interface\n\t\tregister_task = function(taskDef) .. end,  -- PEDT interface\n\t},\n\tresource_status_center = {\n\t\trequire = function(resId) .. end,-- PEDT interface\n\t}\n}\n```\n\n# interfaces\n\n\u003e for detail, @see ${harpseal}/infra/specifications/*\n\u003e \n\u003e for Promise in lua, @see [https://github.com/aimingoo/Promise](https://github.com/aimingoo/Promise)\n\nall interfaces are promise supported except pedt:upgrade() and helpers.\n\n## pedt:run\n\n``` lua\nfunction pedt:run(task, args)\n```\n\nrun a task (taskId, function or taskObject) with args.\n\n## pedt:map\n\n``` lua\nfunction pedt:map(distributionScope, taskId, args)\n```\n\nmap taskId to distributionScope with args, and get result array.\n\ndistributionScope will parse by pedt:require().\n\n## pedt:execute_task\n\n``` lua\nfunction pedt:execute_task(taskId, args)\n```\n\nrun a taskId with args. pedt:run(taskId) will call this.\n\n## pedt:register_task\n\n``` lua\nfunction pedt:register_task(task)\n```\n\nrun a task and return taskId.\n\nthe \"task\" is a taskDef text or local taskObject.\n\n## pedt:require\n\n``` lua\nfunction pedt:require(tokevan)\n```\n\nrequire a resource by token. the token is distributionScope or system token, or other.\n\nthis is n4c expanded interface, resource query interface emmbedded.\n\n## pedt:upgrade\n\n``` lua\nfunction pedt:upgrade(newOptions)\n```\n\nupgrade current Harpseal/PEDT instance with newOptions. @see [options](#options)\n\nthis is harpseal expanded interface.\n\n## pedt.LOGGER\n\nthis is expanded reserved tokens. it's constant:\n\n\u003e LOGGER: \"!\"\n\nso, you can option/reset/upgrade local default logger in your code:\n\n``` javascript\npedt:upgrade({ system_route = {[pedt.LOGGER]: function(_, message) {\n  console.log(message)\n}} });\n```\n\nor disable it:\n\n``` javascript\npedt:upgrade({ system_route = {[pedt.LOGGER] = Promise.resolve(false)} }),\n```\n\nor resend message to remote nodes/scope:\n\n``` javascript\n// @see ${redpoll}/testcase/t_executor.js\npedt:register_task(a_task_def):andThen(set_remote_logger)\n```\n\nand, you can call the logger at anywhere:\n\n``` lua\npedt:require(pedt.LOGGER):andThen(function(logger)\n  pedt:run(logger, message)\nend)\n```\n\nor public a log_print_task, register and run it:\n\n``` lua\nlocal log_print_task = {\n  message = 'will replaced',\n  task = def:require(def.LOGGER),\n  promised = function(self, log)\n    return self:run(log.task, log.message))\n  end\n}\nlocal taskId = '\u003cget result from pedt.register_task(log_print_task)\u003e'\npedt:run(taskId, {message = 'some notice/error information'})\n```\n\nthis is harpseal expanded interface.\n\n## pedt.TASK_XXX\n\nsome task constants, inherited from def.TASK_XXX in Harpseal.infra.taskhelper. include:\n\n``` javascript\nTASK_BLANK\nTASK_SELF\nTASK_RESOURCE\n```\n\nex:\n\n``` lua\ntaskDef = {\n  -- !! static recursion !!\n  x = def:run(def.TASK_SELF, ..), \n  -- require local resource\n  y = def:require('registed_local_resource_name'),\n\n  promised = function(self, taskResult)\n    -- !! dynamic recursion !!\n    self:run(taskResult.taskId, ..);\n    -- try execute blank task\n    self:execute_task(self.TASK_BLANK, {..})\n  end\n}\n```\n\nthis is harpseal expanded interface.\n\n## pedt.version\n\nget support version of PEDT specifications, it's string value.\n\nthis is harpseal expanded interface.\n\n# helpers\n\nsome tool/helpers include in the package.\n\n## Harpseal.infra.taskhelper\n\n``` lua\nlocal Harpseal = require('harpseal');\nlocal def = Harpseal.infra.taskhelper;\n-- or\n-- local def = require('harpseal.infra.taskhelper');\n\nlocal taskDef = {\n\tx = def:run(...),\n\ty = def:map(...),\n\t...\n}\n```\n\na taskDef define helper. @see:\n\n\u003e $(harpseal)/testcase/t_loadTask.lua\n\n## Harpseal.infra.httphelper\n\n``` lua\nlocal Harpseal = require('harpseal');\nlocal httphelper = Harpseal.infra.httphelper;\n-- or\n-- local httphelper = require('harpseal.infra.httphelper');\n\nlocal options = {\n\t...,\n\tdistributed_request = httphelper.distributed_request\n}\n\n-- (...)\n-- (in your business or main, call these)\nhttphelper.start()\n```\n\na recommented/standard distributed request, and activate copas parallel loop with call .start() method in your code.\n\n## Harpseal.tools.taskloader\n\n``` lua\nlocal Harpseal = require('harpseal');\nlocal TaskLoader = Harpseal.tools.taskloader;\n-- or\n-- local TaskLoader = require('harpseal.tools.taskloader');\n\n-- register center for debug only\n--\t*) you can copy dbg_register_center.lua to your project folder from $(harpseal)/infra/, or\n--\t*) require() it when luarocks installed, or\n--\t*) load 3rd register center.\nlocal pedt = Harpseal:new({\n\ttask_register_center = require('harpseal.dbg.register_center'), -- need luarocks\n})\nlocal loader = TaskLoader:new({ publisher = pedt })\n\n-- load task by lua module name\n--\t*) with depth of the discover\nlocal taskId = loader:loadByModule('testcase.tasks.t_task1')\n..\n```\n\na task loader tool, will load tasks by module name of taskDef file, with depth discovery for all members. @see:\n\n\u003e $(harpseal)/testcase/t_loadTask.lua\n\n## pedt.lua utility\n\npedt.lua is a resource management utility. it's a command line tool:\n\n``` bash\n\u003e lua pedt.lua\nUsage:\n\tlua pedt.lua \u003caction\u003e [paraments]\n\tlua pedt.lua help\n\tlua pedt.lua\n```\n\n### action: help\n\nit's default, ex:\n\n``` \n\u003e lua pedt.lua\n```\n\nOr,\n\n``` lua\n\u003e lua pedt.lua help\n\n\u003e # force list center methods for default\n\u003e #   - the default task center is 'infra.dbg_register_center'\n\u003e lua pedt.lua help -l\nMethods:\n\t- report\n\n\u003e # list center methods\n\u003e lua pedt.lua help -t tools.etcd\nMethods:\n\t- show\n\t- list\n```\n\n### action: add\n\nAdd task into task_center, and show taskId. ex:\n\n``` lua\n\u003e echo -n '{}' | lua pedt.lua add\ntask:99914b932bd37a50b983c5e7c90ae93b loaded from json.\n```\n\nthe action usage:\n\n``` center_module_name\nlua pedt.lua add \u003ctask|-\u003e [-t center_module_name] [-c context_type]\n\tparaments:\n    \ttask:\toptional, default is '-', include these types:\n        \t-\t\t\t: char '-', task context from stdin\n            modName\t\t: lua module name, task context from loaded module\n            fileName\t: filename, will call loadfile(fileName)\n            context\t\t: context, will load target module, run and return taskDef\n\t\t-t center_module_name\n        \tdefault is 'infra.dbg_register_center'\n\t\t-c context_type\n        \tcontext types, value include 'module/file/scrip/json'\n```\n\nex:\n\n``` bash\n# add from script string\n\u003e lua pedt.lua add 'return {x=100}' -c 'script'\ntask:898bd5b2c59929cbac99aadc42ce1054 loaded from script.\n\n# add context from json\n\u003e cat infra/samples/taskDef.json | lua pedt.lua add -c 'json'\ntask:68bb82e2a6bcbb5f9a83b93c85cff07a loaded from json.\n\n# add form file\n\u003e echo -n 'return {}' \u003e t.lua\n\u003e lua pedt.lua add ./t.lua -c 'file'\ntask:d751713988987e9331980363e24189ce loaded from file: ./t.lua\n\n\u003e # add from module name\n\u003e lua pedt.lua add t -c 'module'\ntask:d751713988987e9331980363e24189ce loaded from module: t\n```\n\nyou can set a task_center with the center_module_name parament, ex:\n\n``` bash\n\u003e echo -n '{}' | lua pedt.lua add -t 'tools.etcd'\n```\n\nthe 'tools.etcd' module name point to './tools/etcd.lua' file. you midify\n\n\u003e var etcdServer = { url = '...\n\n to config it.\n\n### action: run\n\nRun a task. ex:\n\n``` bash\n# run it\n\u003e echo -n '{}' | lua pedt.lua run -a 'a=1\u0026b=2'\n```\n\nthe action usage:\n\n``` \nlua pedt.lua add \u003ctask|-\u003e [-t center_module_name] [-c context_type] [-a args]\n\tparaments:\n    \ttask:\toptional, default is '-', @see action:add\n\t\t-t center_module_name, @see action:add\n\t\t-c context_type, @see action:add, force set 'task' when \u003ctask\u003e is taskId\n        -a args, url query string or json text\n```\n\nExample 1, with default memory based task center:\n\n``` bash\n# run script from stdin\n\u003e echo -n '{}' | lua pedt.lua run -a 'a=1\u0026b=2'\n{\n  \"a\": \"1\",\n  \"b\": \"2\"\n}\n\n# with json arguments\n\u003e echo -n '{}' | lua pedt.lua run -a '{\"x\":1, \"y\":false}'\n{\n  \"x\": 1,\n  \"y\": false\n}\n\n# execute task from script, and with arguments\n\u003e lua pedt.lua run -c 'script' -a '{\"message\": \"Hello World!\"}'\\\n\t'return {promised=function(_, r) print(r.message); return true end}'\nHello World!\ntrue\n```\n\nExample 2, with specific task center:\n\n``` bash\n# add a task into task center\n\u003e echo -n '{}' | lua pedt.lua add -t tools.etcd\ntask:99914b932bd37a50b983c5e7c90ae93b loaded from json.\n\n# and, run the task from specific task center\n\u003e lua pedt.lua run 'task:99914b932bd37a50b983c5e7c90ae93b' -a '{\"x\":1, \"y\":false}' -t tools.etcd\n{\n  \"x\": 1,\n  \"y\": false\n}\n```\n\n### action: methods\n\nexecute a task center specific method. ex:\n\n``` bash\n\u003e lua pedt.lua report\n=============================================\nOUTPUT dbg_storage\n=============================================\n```\n\nUsage:\n\n``` \nlua pedt.lua \u003cmethod\u003e [task] [-a args]\n\tparaments:\n    \ttask:\toptional, default is none\n        -a args, url query string or json text\n```\n\nex:\n\n``` bash\n# first, list methods for task center\n\u003e lua pedt.lua help -t tools.etcd\nMethods:\n\t - show\n\t - list\n\n# next, run 'list' method as action\n\u003e lua pedt.lua list -t tools.etcd\n1\t/N4C/task_center/tasks/99914b932bd37a50b983c5e7c90ae93b\n2\t/N4C/task_center/tasks/d751713988987e9331980363e24189ce\n3\t/N4C/task_center/tasks/778e25e48daf7a9ab49d00909afbdaa4\n\n# and, show a task\n\u003e lua pedt.lua show '778e25e48daf7a9ab49d00909afbdaa4' -t 'tools.etcd'\n{\n  \"info\": {\n    \"arguments\": {\n      \"p1\": \"new value\"\n    },\n    \"run\": \"script:javascript:base64:ZnVuY3Rpb24gb...\"\n  },\n  \"p1\": \"default value\"\n}\n```\n\n# testcase\n\ntry these:\n\n``` bash\n\u003e # launch redpoll as service, require NodeJS\n\u003e # (for test only)\n\u003e git clone https://github.com/aimingoo/redpoll\n\u003e node redpoll/testcase/t_executor.js\n\n\u003e # start new shell and continue\n\u003e luarocks install luasocket\n\u003e luarocks install copas\n\u003e git clone 'https://github.com/aimingoo/harpseal'\n\u003e cd harpseal\n\u003e lua testcase/t_loadTask.lua\n```\n\n# history\n\n``` text\n2015.12.04\tv1.0.4 released.\n\t- sync to redpoll v1.1.2, support default_rejected and logger.\n    - add pedt.lua, a utility for task/resource center.\n    - fix bug: extractTaskResult() cant process value type taskResult.\n2015.11.08\tv1.0.3 released.\n\t- minor changes for luarocks.\n\t- done.\n2015.11.08\tv1.0.2 released.\n\t- minor changes and rockspec updated again.\n\t- a register center published at harpseal.dbg.register_center.\n2015.11.08\tv1.0.1 released.\n\t- minor changes and rockspec updated.\n2016.11.08\tv1.0.0 released.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faimingoo%2Fharpseal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faimingoo%2Fharpseal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faimingoo%2Fharpseal/lists"}