Created
September 22, 2015 22:32
-
-
Save lcaballero/66d371a335672a27e74c to your computer and use it in GitHub Desktop.
Go example of connection based handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Db struct { | |
db *bolt.DB | |
err error | |
} | |
func (d *Db) start() *bolt.DB { | |
d.db, d.err = bolt.Open("my.db", 0600, nil) | |
if d.err != nil { | |
fmt.Println(d.err) | |
} | |
go func() { | |
death.NewDeath(syscall.SIGINT, syscall.SIGTERM).WaitForDeath(d.db) | |
}() | |
return d.db | |
} | |
func NewDb() *Db { | |
return &Db{} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment