Documentation ¶
Overview ¶
https://github.com/kintoandar/fwd
https://github.com/elazarl/goproxy
https://github.com/carlescere/scheduler Package scheduler is a cron replacement based on:
http://adam.herokuapp.com/past/2010/4/13/rethinking_cron/
and
https://github.com/dbader/schedule
Uses include:
func main() { job := func() { fmt.Println("Time's up!") } scheduler.Every(5).Seconds().Run(function) scheduler.Every().Day().Run(function) scheduler.Every().Sunday().At("08:30").Run(function) }
Index ¶
- func AddPath(env string, p []string) string
- func BackoffDuration() func(error)
- func CurrentTime() int64
- func DefaultEnviron(base string) []string
- func Execute(base, file string, args ...string) error
- func Forward(from, to string)
- func FreePort() int
- func GetIntEnv(env string, i int) int
- func HTTPProxy(port int, nb *Neighborhood)
- func HealthHandlerFunc(proxyURL string) http.HandlerFunc
- func IsLocalHost(host string) bool
- func LocalProxy(port int)
- func Logger() *logrus.Entry
- func MuxHandlerFunc(proxyURL string) http.HandlerFunc
- func P2PCloseAll() error
- func P2PListen(appPort int) error
- func PACHandlerFunc(proxyURL string) http.HandlerFunc
- func ParseInt(s string, v int) int
- func PathJoinList(p []string) string
- func PeerTLD(domain string) string
- func SetDefaultEnviron(base string)
- func StartGPM(base string)
- func StartProxy(cfg *Config)
- func TLD(domain string) string
- func ToPeerAddr(s string) string
- func ToPeerID(s string) string
- func ToTimestamp(d time.Time) int64
- func W3Proxy(pid string, port int)
- type AppDesc
- type Backend
- type Config
- type GPM
- type Health
- type Job
- func (j *Job) At(hourTime string) *Job
- func (j *Job) Day() *Job
- func (j *Job) Friday() *Job
- func (j *Job) Hours() *Job
- func (j *Job) IsRunning() bool
- func (j *Job) Minutes() *Job
- func (j *Job) Monday() *Job
- func (j *Job) NotImmediately() *Job
- func (j *Job) Run(f func()) (*Job, error)
- func (j *Job) Saturday() *Job
- func (j *Job) Seconds() *Job
- func (j *Job) Sunday() *Job
- func (j *Job) Thursday() *Job
- func (j *Job) Tuesday() *Job
- func (j *Job) Wednesday() *Job
- type ListFlags
- type Neighborhood
- type Node
- type Peer
- type Peers
- type Route
- type RouteRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultEnviron ¶
DefaultEnviron returns required env slice for running core services
func HTTPProxy ¶
func HTTPProxy(port int, nb *Neighborhood)
HTTPProxy dispatches request based on network addr
func HealthHandlerFunc ¶
func HealthHandlerFunc(proxyURL string) http.HandlerFunc
func IsLocalHost ¶
IsLocalHost checks whether host is explicitly local host taken from goproxy
func MuxHandlerFunc ¶
func MuxHandlerFunc(proxyURL string) http.HandlerFunc
MuxHandlerFunc multiplexes requests
func P2PCloseAll ¶
func P2PCloseAll() error
func PACHandlerFunc ¶
func PACHandlerFunc(proxyURL string) http.HandlerFunc
PACHandlerFunc handles PAC file request
func PathJoinList ¶
PathJoinList is the inverse operation of filepath.SplitList
func SetDefaultEnviron ¶
func SetDefaultEnviron(base string)
SetDefaultEnviron sets required env for running core services
func ToPeerAddr ¶
ToPeerAddr returns b32-encoded ID. it converts to b32 if B58-encoded.
func ToTimestamp ¶
Types ¶
type AppDesc ¶
type AppDesc struct { Name string `json:"name"` Command string `json:"command"` AutoRestart bool `json:"autoRestart"` After string `json:"after"` WorkingDirectory string `json:"workDir"` }
func LoadAppDesc ¶
LoadAppDesc loads app configuration by name from ./, $dhnt_base/etc/ or $HOME/dhnt/etc/
type Job ¶
type Job struct { Quit chan bool SkipWait chan bool sync.RWMutex // contains filtered or unexported fields }
Job defines a running job and allows to stop a scheduled job or run it.
func Every ¶
Every defines when to run a job. For a recurrent jobs (n seconds/minutes/hours) you should specify the unit and then call to the correspondent period method.
func (*Job) At ¶
At lets you define a specific time when the job would be run. Does not work with recurrent jobs. Time should be defined as a string separated by a colon. Could be used as "08:35:30", "08:35" or "8" for only the hours.
func (*Job) Hours ¶
Hours sets the job to run every n Hours where n was defined in the Every function.
func (*Job) Minutes ¶
Minutes sets the job to run every n Minutes where n was defined in the Every function.
func (*Job) NotImmediately ¶
NotImmediately allows recurrent jobs not to be executed immediatelly after definition. If a job is declared hourly won't start executing until the first hour passed.
func (*Job) Run ¶
Run sets the job to the schedule and returns the pointer to the job so it may be stopped or executed without waiting or an error.
type ListFlags ¶
type ListFlags []string
ListFlags is for collecting an array of command line arguments
type Neighborhood ¶
type Neighborhood struct { Peers map[string]*Peer My *Node Router *RouteRegistry sync.Mutex // contains filtered or unexported fields }
Neighborhood is
func (*Neighborhood) AddPeerProxy ¶
func (r *Neighborhood) AddPeerProxy(id string) string
func (*Neighborhood) GetPeerTarget ¶
func (r *Neighborhood) GetPeerTarget(id string) string
GetPeerTarget returns peer proxy host:port
func (*Neighborhood) IsReady ¶
func (r *Neighborhood) IsReady() bool
IsReady tests if node is available
type Node ¶
type Node struct { ID string PublicKey string Addresses []string AgentVersion string ProtocolVersion string }
Node is
type Peer ¶
type Peer struct { Port int Peer string Latency string Muxer string Streams []struct { Protocol string } Rank int // -1, 0, 1 ... // contains filtered or unexported fields }
Peer is
type RouteRegistry ¶
type RouteRegistry struct { MyID string MyAddr string Routes []*Route // contains filtered or unexported fields }
RouteRegistry stores the routing configuration.
func NewRouteRegistry ¶
func NewRouteRegistry(myid string) *RouteRegistry
NewRouteRegistry instantiates a new route registry
func (*RouteRegistry) Match ¶
func (c *RouteRegistry) Match(hostname string) ([]*Backend, bool)
Match returns the backend for hostname, and whether to use proxy.
func (*RouteRegistry) Read ¶
func (c *RouteRegistry) Read(reader io.Reader) error
Read replaces current config
func (*RouteRegistry) ReadFile ¶
func (c *RouteRegistry) ReadFile(path string) error
ReadFile replaces the current routes with one read from path.
func (*RouteRegistry) ReadString ¶
func (c *RouteRegistry) ReadString(cfg string) error
ReadString replaces the current routes with one read from cfg.