Documentation
¶
Overview ¶
Simple skeleton for background processes
Example ¶
package main
import (
"fmt"
"github.com/bitmark-inc/bitmarkd/background"
"time"
)
type theState struct {
count int
}
func main() {
proc := &theState{
count: 10,
}
// list of background processes to start
processes := background.Processes{
proc,
}
p := background.Start(processes, nil)
time.Sleep(time.Second)
p.Stop()
}
func (state *theState) Run(args interface{}, shutdown <-chan struct{}) {
fmt.Printf("initialise\n")
loop:
for {
select {
case <-shutdown:
break loop
default:
}
state.count += 1
time.Sleep(time.Millisecond)
}
fmt.Printf("finalise\n")
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Process ¶
type Process interface {
Run(args interface{}, shutdown <-chan struct{})
}
type signature for background process and type that implements this Run is a process
Click to show internal directories.
Click to hide internal directories.