1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-06 03:27:27 +00:00
Read HISTORY.md
This commit is contained in:
Gerasimos Maropoulos
2016-09-27 16:28:38 +03:00
parent 70d81e6843
commit 5c98c5a493
16 changed files with 1160 additions and 2273 deletions

View File

@@ -1,6 +0,0 @@
## Package information
This package contains helpful functions that iris, internally, uses
**That's it.**

View File

@@ -1,22 +0,0 @@
package utils
import (
"github.com/kataras/go-errors"
)
var (
// ErrNoZip returns an error with message: 'While creating file '+filename'. It's not a zip'
ErrNoZip = errors.New("While installing file '%s'. It's not a zip")
// ErrFileOpen returns an error with message: 'While opening a file. Trace: +specific error'
ErrFileOpen = errors.New("While opening a file. Trace: %s")
// ErrFileCreate returns an error with message: 'While creating a file. Trace: +specific error'
ErrFileCreate = errors.New("While creating a file. Trace: %s")
// ErrFileRemove returns an error with message: 'While removing a file. Trace: +specific error'
ErrFileRemove = errors.New("While removing a file. Trace: %s")
// ErrFileCopy returns an error with message: 'While copying files. Trace: +specific error'
ErrFileCopy = errors.New("While copying files. Trace: %s")
// ErrFileDownload returns an error with message: 'While downloading from +specific url. Trace: +specific error'
ErrFileDownload = errors.New("While downloading from %s. Trace: %s")
// ErrDirCreate returns an error with message: 'Unable to create directory on '+root dir'. Trace: +specific error
ErrDirCreate = errors.New("Unable to create directory on '%s'. Trace: %s")
)

View File

@@ -1,64 +0,0 @@
/* ticker.go: after version 1, we don't need this atm, but we keep it. */
package utils
import (
"time"
)
// Ticker is the timer which is used in cache
type Ticker struct {
ticker *time.Ticker
started bool
tickHandlers []func()
}
// NewTicker returns a new Ticker
func NewTicker() *Ticker {
return &Ticker{tickHandlers: make([]func(), 0), started: false}
}
// OnTick add event handlers/ callbacks which are called on each timer's tick
func (c *Ticker) OnTick(h func()) {
c.tickHandlers = append(c.tickHandlers, h)
}
// Start starts the timer and execute all listener's when tick
func (c *Ticker) Start(duration time.Duration) {
if c.started {
return
}
if c.ticker != nil {
panic("Iris Ticker: Cannot re-start a cache timer, if you stop it, it is not recommented to resume it,\n Just create a new CacheTimer.")
}
c.ticker = time.NewTicker(duration)
go func() {
for t := range c.ticker.C {
_ = t
// c.mu.Lock()
// c.mu.Unlock()
//I can make it a clojure to handle only handlers that are registed before .start() but we are ok with this, it is not map no need to Lock, for now.
for i := range c.tickHandlers {
c.tickHandlers[i]()
}
}
}()
c.started = true
}
// Stop stops the ticker
func (c *Ticker) Stop() {
if c.started {
c.ticker.Stop()
c.started = false
}
}
// ITick is the interface which all ticker's listeners must implement
type ITick interface {
OnTick()
}