{"id":19713487,"url":"https://github.com/shalomb/nq","last_synced_at":"2026-06-10T03:31:14.043Z","repository":{"id":101380223,"uuid":"562546449","full_name":"shalomb/nq","owner":"shalomb","description":"Simple last-job-in-queue command executor","archived":false,"fork":false,"pushed_at":"2024-07-15T16:32:13.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T20:33:14.612Z","etag":null,"topics":["build-tool","ci-tool","command-executor","go-cli","job-queue","test-runner"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shalomb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-06T17:28:17.000Z","updated_at":"2024-07-15T16:32:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"2270f8fd-6998-4bc7-a5f6-45747dd31886","html_url":"https://github.com/shalomb/nq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shalomb/nq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalomb%2Fnq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalomb%2Fnq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalomb%2Fnq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalomb%2Fnq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shalomb","download_url":"https://codeload.github.com/shalomb/nq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalomb%2Fnq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34136112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"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":["build-tool","ci-tool","command-executor","go-cli","job-queue","test-runner"],"created_at":"2024-11-11T22:22:53.134Z","updated_at":"2026-06-10T03:31:14.029Z","avatar_url":"https://github.com/shalomb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"nq(1) - A simple last-in-queue command executor\n\n```\n# Start the server\n\n$ nq -s\nINFO[21:06:15.9488] Server requested. Starting server\n...\nINFO[21:06:15.952] Setting up worker\nINFO[21:06:15.9521] Worker started\n\n\n# In another shell - push commands to the server\n\n$ nq -- sh -c 'make build test'  # Queued, starts running, returns immediately, does not block\n$ nq -- sh -c 'make build test'  # Queued, likely never runs\n$ nq -- sh -c 'make build test'  # Queued, likely never runs\n$ nq -- sh -c 'make build test'  # Queued, runs\n```\n\n## Why?\n\nIn most build pipelines, processing build tasks/jobs is a blocking activity\nand this causes a problem in managing queues where multiple _fire-and-forget_\njobs can be submitted.\n\nIf jobs are submitted at a rate  greater than the processing time - two\nunwanted things arise\n\n- (1) the queue length increases\n- (2) new commands cannot be submitted as the previous commands block\n\n`nq` allows the non-blocking intake of multiple (identical) jobs and will\nbegin processing the last job in the job queue, ignoring and discarding all\nthe others that precede it.\n\nAdditionally, the `nq` client does not block, it returns immediately after pushing the\njob command to the server. This frees up the shell allowing `nq` to be\ninvoked again. In this mode `nq` does not wait to check the exit status\nof the command(s) submitted to the queue.\n\n### Use case - Triggering builds from file changes in the editor\n\ne.g. in vim + tmux/tslime, you may wish to run tests on every buffer/file write\n\n```\n:au BufWritePost,FileWritePost * silent :Tmux make build test\n```\n\nHere `make` blocks until it has finished processing.\n\nWith `nq` wrapping the command, flow is non-blocking\n\n```\n:au BufWritePost,FileWritePost * silent :Tmux nq -- make build\n```\n\n### Use case - Running builds from file changes detected by inotify, etc\n\n`nq` can listen in on STDIN being a pipe and react only when the input\nmatches a regular expression.\n\n```\ninotifywait -q -e close_write -m . | nq -p CREATE -- make build test\n```\n\n## Integrations with custom clients\n\nSimply write an array of strings as a JSON string to the named pipe.\n\n```\n{ echo -e '[\"sh\", \"-c\", \"'echo foo'\"]';  } \u003e \"$TMP/nq.fifo\"\n```\n\n## Building nq\n\n```\n$ make build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshalomb%2Fnq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshalomb%2Fnq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshalomb%2Fnq/lists"}