百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

garr

> 数据库
开源

高性能、线程安全、无锁的 go 数据结构集合

370 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

高性能、线程安全、无锁的 go 数据结构集合

Garr - Go libs in a Jar

Collection of high performance, thread-safe, lock-free go data structures.

  • adder - Data structure to perform highly-performant sum under high contention. Inspired by OpenJDK LongAdder
  • circuit-breaker - Data structure to implement circuit breaker pattern to detect remote service failure/alive status.
  • queue - Queue data structure, go implementation of JDKLinkedQueue and MutexLinkedQueue from OpenJDK.
  • retry - Controls backoff between attempts in a retry operation.
  • worker-pool - Worker pool implementation in go to help perform multiple tasks concurrently with a fixed-but-expandable amount of workers.

Usage

Getting started

bash
go get -u go.linecorp.com/garr

Examples

Please find detailed examples in each sub-package.

Adder

…

Queue

go
package main

import (
    "fmt"

    "go.linecorp.com/garr/queue"
)

func main() {
    q := queue.DefaultQueue() // default using jdk linked queue

    // push
    q.Offer(123)

    // return head queue but not remove
    head := q.Peek()
    fmt.Println(head)

    // remove and return head queue
    polled := q.Poll()
    fmt.Println(polled)
}

Circuit Breaker

go
package main

import (
    cbreaker "go.linecorp.com/garr/circuit-breaker"
)

func makeRequest() error {
	return nil
}

func main() {
    cb := cbreaker.NewCircuitBreakerBuilder().
                        SetTicker(cbreaker.SystemTicker).
                        SetFailureRateThreshold(validFailureRateThreshold).
                        Build()

    if cb.CanRequest() {
        err := makeRequest()
        if err != nil {
            cb.OnFailure()
        } else {
            cb.OnSuccess()
        }
    }
}

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogolanghigh-performancelibrarylock-free

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库