Documentation
¶
Overview ¶
Package config contains common goconfigure compatible configuration blocks.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// Type of limiter
Type string
// Depth of the limiter (i.e. number of distinct items to hold)
Depth int
// Limit at which the limiter will trip (i.e. the number of time something
// needs to be seen before the limiter trips)
Limit int
// TTL for the items in the limiter
TTL time.Duration
// DefaultLimit for this limiter
DefaultLimit int
}
Limiter configuration.
func NewLimiter ¶
NewLimiter returns a limiter of the specified type and default limit.
func (*Limiter) Register ¶
func (l *Limiter) Register(opts goconfigure.OptionSet)
Register the limiter.
type Limiters ¶
type Limiters struct {
// Source limiter rate limits connections from the same source.
Source *Limiter
// User limiter rate limits connections from the same user.
User *Limiter
}
Limiters in use by the system.
func (*Limiters) Configure ¶
func (l *Limiters) Configure(config *goconfigure.Settings)
Configure the limiter.
Example ¶
package main
import (
"fmt"
"bitbucket.org/idomdavis/goconfigure"
"bitbucket.org/idomdavis/gohttp/config"
)
func main() {
l := config.Limiters{}
s := goconfigure.NewSettings("TLS")
l.Configure(s)
err := s.ParseUsing([]string{
"--user-limiter-depth", "10", "--source-limiter-depth", "50",
}, goconfigure.ConsoleReporter{})
if err != nil {
fmt.Println(err)
}
}
Output: Source Limiter Settings: [Depth:50, Limit:100, TTL:1s, Type:Source] User Limiter Settings: [Depth:10, Limit:5, TTL:1s, Type:User]
type TLS ¶
type TLS struct {
// Key is the path to the TLS key.
Key string `json:"TLS Key Path"`
// Certificate is the path to the TLS Certificate.
Certificate string `json:"TLS Certificate Path"`
}
TLS options.
func (*TLS) Register ¶
func (t *TLS) Register(opts goconfigure.OptionSet)
Register the TLS options.
Example ¶
package main
import (
"fmt"
"bitbucket.org/idomdavis/goconfigure"
"bitbucket.org/idomdavis/gohttp/config"
)
func main() {
tls := config.TLS{}
s := goconfigure.NewSettings("TLS")
s.Add(&tls)
err := s.ParseUsing([]string{
"-tls-key", "./tls.key", "--tls-certificate", "./tls.cert",
}, goconfigure.ConsoleReporter{})
if err != nil {
fmt.Println(err)
}
}
Output: TLS settings: [TLS Certificate Path:./tls.cert, TLS Key Path:./tls.key]
Click to show internal directories.
Click to hide internal directories.