Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

moeryomenko/debouncer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Debouncer

Library for suppress duplicated calls in distributed systems.

Supported distributed cache and locker

  • Redis
  • Memcached
  • Tarantool(coming soon)

Usage

package main import ( "time" "github.com/moeryomenko/debouncer"	cache "github.com/moeryomenko/ttlcache" ) func main() { // create distributed suppressor. redisCache, redisLocker := adapters.NewRedisDriver(redis.NewClient(&redis.Options{Addr: "<ip:port>"})) suppressor, err := debouncer.NewDebouncer(debouncer.Config{ Local: { TTL: time.Second, Caceh: cache.NewCache(100, cache.ARC),	}, Distributed: { Cache: redisCache, Locker: redisLocker, Retry: 20 * time.Millisecond, TTL: 3 * time.Second,	},	}) if err != nil { panic("could not create suppressor")	} ... result, err := suppressor.Do(key /* token for acquire fn */, fn) if err != nil { panic("something gone wrong")	} ... }

License

Debouncer is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and/or LICENSE-MIT for details.

About

Suppressor duplicated calls in distributed systems.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors