Skip to content

Commit 3663d70

Browse files
committed
Added Quit method
1 parent 6bbbddc commit 3663d70

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

discovery_server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ type Discovery interface {
7272
// in event mode it must stop sending events through the eventCB previously
7373
// set.
7474
Stop() error
75+
76+
// Quit is called just before the server terminates. This function can be
77+
// used by the discovery as a last chance gracefully close resources.
78+
Quit()
7579
}
7680

7781
// EventCallback is a callback function to call to transmit port
@@ -135,6 +139,7 @@ func (d *DiscoveryServer) Run(in io.Reader, out io.Writer) error {
135139
case "STOP":
136140
d.stop()
137141
case "QUIT":
142+
d.impl.Quit()
138143
d.outputOk("quit")
139144
return nil
140145
default:

dummy-discovery/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func (d *DummyDiscovery) Hello(userAgent string, protocol int) error {
4747
return nil
4848
}
4949

50+
func (d *DummyDiscovery) Quit() {}
51+
5052
func (d *DummyDiscovery) List() ([]*discovery.Port, error) {
5153
d.listCount++
5254
if d.listCount%5 == 0 {

0 commit comments

Comments
 (0)