mirror of
https://github.com/safing/portbase
synced 2025-09-10 06:15:08 +00:00
Initial commit after restructure
This commit is contained in:
commit
96ec15b39b
70 changed files with 6945 additions and 0 deletions
50
modules/modules_test.go
Normal file
50
modules/modules_test.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Copyright Safing ICS Technologies GmbH. Use of this source code is governed by the AGPL license that can be found in the LICENSE file.
|
||||
|
||||
package modules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func newTestModule(name string, order uint8) {
|
||||
|
||||
fmt.Printf("up %s\n", name)
|
||||
module := Register("TestModule", order)
|
||||
|
||||
go func() {
|
||||
<-module.Stop
|
||||
fmt.Printf("down %s\n", name)
|
||||
module.StopComplete()
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
func Example() {
|
||||
|
||||
// wait for logger registration timeout
|
||||
time.Sleep(1010 * time.Millisecond)
|
||||
|
||||
newTestModule("1", 1)
|
||||
newTestModule("4", 4)
|
||||
newTestModule("3", 3)
|
||||
newTestModule("2", 2)
|
||||
newTestModule("5", 5)
|
||||
|
||||
InitiateFullShutdown()
|
||||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
// Output:
|
||||
// up 1
|
||||
// up 4
|
||||
// up 3
|
||||
// up 2
|
||||
// up 5
|
||||
// down 5
|
||||
// down 4
|
||||
// down 3
|
||||
// down 2
|
||||
// down 1
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue