Skip to content

kavehmz/counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

counter

GoDoc Build Status Coverage Status Go Report Card

This is a Go library to increment a counter for a window of time (say last 60 second). Its resolution is 1 second.

Results will be periodically saved in a local file.

Installation

$ go get github.com/kavehmz/counter

Usage

# to test it as a http server you can do:
$ go run -race example/main.go
package main

import (
    "fmt"
    "github.com/kavehmz/counter"
)

func main() {
    c := counter.Init("/tmp/counter", time.Second, 60)
    ch := make(chan int)
    c.Inc(ch)
    fmt.Println(<-ch)
}

Algorithm

This lib is using and travesing a linked list to keep track of counts.

About

A file persistent counter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages