mirror of
https://github.com/gitpitch/gitpitch.git
synced 2024-04-18 07:30:55 +08:00
30 lines
611 B
Go
30 lines
611 B
Go
|
package funding
|
||
|
|
||
|
type FundServer struct {
|
||
|
Commands chan interface{}
|
||
|
fund Fund
|
||
|
}
|
||
|
|
||
|
func NewFundServer(initialBalance int) *FundServer {
|
||
|
server := &FundServer{
|
||
|
// make() creates builtins like channels
|
||
|
Commands: make(chan interface{}),
|
||
|
fund: NewFund(initialBalance),
|
||
|
}
|
||
|
|
||
|
// Spawn off the server's main loop immediately
|
||
|
go server.loop()
|
||
|
return server
|
||
|
}
|
||
|
|
||
|
func (s *FundServer) loop() {
|
||
|
// The built-in "range" clause can iterate
|
||
|
// over channels, amongst other things
|
||
|
for command := range s.Commands {
|
||
|
|
||
|
// Handle the command
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|