Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

garr

> 数据库
Open source

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

370 stars0 likes2 views
WebsiteGitHub

About

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

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 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gogolanghigh-performancelibrarylock-free

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

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