Skip to content

cookingkode/gohystrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

gohystrix

Simple wrapper for Hystrix Command pattern

This project is inspired by the Netflix Hystrix project :http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html

The initial commit contains implementation for the Command pattern. Once can define a function, timeout and a fallback.

***Usage: **

package main

import (
    "fmt"
    "gohystrix"
    "time"
)

func mainFunction(param interface{}) interface{} {
    d := param.(int)

    time.Sleep(time.Second * 3) // Vary this to force/not timeout
    fmt.Println("Main Function ", d)

    return d * 2
}

func fallback(param interface{}) interface{} {
    d := param.(int)
    fmt.Println("FALLBACK ", d)

    return d * 4
}

func main() {

    cmd := gohystrix.NewCommand(mainFunction, fallback, 2000)
    res := cmd.Run(2)
    fmt.Println(res)

}

About

Simple wrapper for Hystrix Command pattern

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages