{"id":36577206,"url":"https://github.com/z0rr0/hashq","last_synced_at":"2026-01-12T07:37:15.224Z","repository":{"id":30615880,"uuid":"34171246","full_name":"z0rr0/hashq","owner":"z0rr0","description":"Go package to control incoming tasks that need to use some shared resources.","archived":false,"fork":false,"pushed_at":"2015-09-23T20:18:47.000Z","size":240,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T13:12:21.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/z0rr0.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-04-18T15:34:50.000Z","updated_at":"2015-04-20T20:05:08.000Z","dependencies_parsed_at":"2022-08-03T15:14:43.804Z","dependency_job_id":null,"html_url":"https://github.com/z0rr0/hashq","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/z0rr0/hashq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z0rr0%2Fhashq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z0rr0%2Fhashq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z0rr0%2Fhashq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z0rr0%2Fhashq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/z0rr0","download_url":"https://codeload.github.com/z0rr0/hashq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/z0rr0%2Fhashq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-12T07:37:15.163Z","updated_at":"2026-01-12T07:37:15.211Z","avatar_url":"https://github.com/z0rr0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## hashq\n\n[![GoDoc](https://godoc.org/github.com/z0rr0/hashq?status.svg)](https://godoc.org/github.com/z0rr0/hashq) [![LGPL License](http://img.shields.io/badge/license-LGPLv3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0.txt) [![Build Status](https://travis-ci.org/z0rr0/hashq.svg?branch=master)](https://travis-ci.org/z0rr0/hashq)\n\nGo package to control incoming tasks that need to use some shared resources.\n\nIt contains a storage for some resources. Unused elements will be closed automatically after needed time.\n\nFor example, it can be used if there are many incoming requests and every one should read some data from database. So, some shared connections pool can be allocated and used, and we shouldn't control it, **hashq** will store a set and return needed elements using round robin algorithm.\n\nVersion 2.0 is not backwards compatible with previous ones. There are following main changes:\n\n* element's interface is changed, it contains methods Close() and CanClose()\n* new HashQ constructor with 3 parameters\n* the pool doesn't control custom locks/unlocks operation and works only as a storage\n* the pool doesn't use time hashing now, the round robing algorithm is used\n\n```go\nvar (\n    poolSize int64 = 128              // storage size\n    cleanPeriod    = 90 * time.Second // Clean() function will be called after this period\n    waitAfterClose = 1 * time.Second  // wait this period after connection close\n)\n\ntype Connection struct {\n\t// some fields\n}\n// to initialize the pool by initial values\n// often, it empty structure or its pointer\nfunc (con *Connection) New() Shared {...}\n// Close tries to close an object\n// and returns true if it did it.\n// It should contain all needed locks/unlocks.\nfunc (con *Connection) Close() {...}\n\n// create new pool\npool := New(poolSzie, \u0026Connection{}, 0)\nch, errc := make(chan Shared), make(chan error)\n// the pool will send new elements to channel ch\ngo pool.Produce(ch, ec)\n// check that Producer is started without any errors\nif err := \u003c-errc; err == nil {\n    panic(err)\n}\n// Monitor can be periodically called to run CanClose+Close\n// for each element in the pool\ngo pool.Monitor(cleanPeriod)\n// get element\nsh := \u003c-ch\nconn := sh.(*Connection)\n// use conn...\n```\n\n### Dependencies\n\nStandard [Go library](http://golang.org/pkg/).\n\n### Design guidelines\n\nThere are recommended style guides:\n\n* [The Go Programming Language Specification](https://golang.org/ref/spec)\n* [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments).\n\n[Go-lint](http://go-lint.appspot.com/github.com/z0rr0/hashq) tool.\n\n### Testing\n\nStandard Go testing way:\n\n```shell\ncd $GOPATH/src/github.com/z0rr0/hashq\ngo test -v -cover\n```\n\n---\n\n*This source code is governed by a [LGPLv3](https://www.gnu.org/licenses/lgpl-3.0.txt) license that can be found in the [LICENSE](https://github.com/z0rr0/hashq/blob/master/LICENSE) file.*\n\n\u003cimg src=\"https://www.gnu.org/graphics/lgplv3-147x51.png\" title=\"LGPLv3 logo\"\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz0rr0%2Fhashq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fz0rr0%2Fhashq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fz0rr0%2Fhashq/lists"}