restrix

package module
v0.0.0-...-2b89f63 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2017 License: MIT Imports: 5 Imported by: 14

README

REST Layer Hystrix storage handler wrapper

godoc license build

This REST Layer resource storage wrapper uses hystrix-go to add circuit breaker support to any REST Layer resource storage handler.

Usage

import "github.com/rs/rest-layer-hystrix"

Wrap existing storage handler with a name that will be used to construct hystrix commands:

s := restrix.Wrap("myResource", mem.NewHandler())

Use this handler with a resource:

index.Bind("foo", foo, s, resource.DefaultConf)

Customize the hystrix commands:

// Configure hystrix commands
hystrix.Configure(map[string]hystrix.CommandConfig{
    "posts.Find": {
        Timeout:               1000,
        MaxConcurrentRequests: 100,
        ErrorPercentThreshold: 25,
    },
    "posts.Insert": {
        Timeout:               1000,
        MaxConcurrentRequests: 50,
        ErrorPercentThreshold: 25,
    },
    ...
})

Start the metrics stream handler:

hystrixStreamHandler := hystrix.NewStreamHandler()
hystrixStreamHandler.Start()
log.Print("Serving Hystrix metrics on http://localhost:8081")
go http.ListenAndServe(net.JoinHostPort("", "8081"), hystrixStreamHandler)

Documentation

Overview

Package restrix is a REST Layer resource storage wrapper to add hystrix support to the underlaying storage handler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(name string, h resource.Storer) resource.Storer

Wrap wraps a REST Layer storage handler to add hystrix support to all handler's methods.

Hystrix wraps each storage handlers into an hystrix command. One hystrix command is created per backend actions with the format <name>.<Action>.

Actions are Find, Insert, Update, Delete, Clear and MultiGet for handlers implementing MultiGetter interface.

You must configure hystrix for each command you want to control and start the stream handler. See https://godoc.org/github.com/afex/hystrix-go/hystrix for more info and examples/hystrix/main.go for a usage example.

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL