tracker: Add common interface to start and stop servers

This commit is contained in:
Justin Li
2015-02-20 13:39:19 -05:00
parent 0d33210901
commit 92f3c62456
4 changed files with 106 additions and 35 deletions
+9
View File
@@ -24,6 +24,15 @@ type Tracker struct {
*Storage
}
// Server represents a server for a given BitTorrent tracker protocol.
type Server interface {
// Serve runs the server and blocks until the server has shut down.
Serve()
// Stop cleanly shuts down the server in a non-blocking manner.
Stop()
}
// New creates a new Tracker, and opens any necessary connections.
// Maintenance routines are automatically spawned in the background.
func New(cfg *config.Config) (*Tracker, error) {