Skip to content

Instantly share code, notes, and snippets.

View daholino's full-sized avatar
🏠
Working from home

Tarik daholino

🏠
Working from home
View GitHub Profile
@daholino
daholino / limiter.go
Created August 21, 2023 16:43
Limit concurrent function executions using Go channels
package limiter
import (
"errors"
"time"
)
type Limiter struct {
timeout time.Duration
ch chan struct{}
@daholino
daholino / executor.go
Created August 8, 2023 21:05
Non-blocking sequential processing in Go, infinite (unbounded) buffered channel
package executor
type ExecHandler[T any] func(T)
type Executor[T any] struct {
reader chan T
writer chan T
buffer []T
execHandler ExecHandler[T]
}