Fixed the request and added a timeout
This commit is contained in:
parent
e34d766bf5
commit
5fc1c8fb95
1 changed files with 10 additions and 10 deletions
20
main.go
20
main.go
|
@ -157,8 +157,17 @@ func Main(information library.ServiceInitializationInformation) {
|
|||
Message: nil,
|
||||
}
|
||||
|
||||
var publicKey ed25519.PublicKey = nil
|
||||
|
||||
// 10 second timeout
|
||||
go func() {
|
||||
time.Sleep(10 * time.Second)
|
||||
if publicKey == nil {
|
||||
logFunc("Timeout while waiting for the public key from the authentication service", 3, information)
|
||||
}
|
||||
}()
|
||||
|
||||
// Wait for the response
|
||||
var publicKey ed25519.PublicKey
|
||||
response = <-information.Inbox
|
||||
if response.MessageType == 2 {
|
||||
// This is the public key
|
||||
|
@ -169,15 +178,6 @@ func Main(information library.ServiceInitializationInformation) {
|
|||
logFunc(response.Message.(error).Error(), 3, information)
|
||||
}
|
||||
|
||||
// Ask the authentication service for its host name
|
||||
information.Outbox <- library.InterServiceMessage{
|
||||
ServiceID: ServiceInformation.ServiceID,
|
||||
ForServiceID: uuid.MustParse("00000000-0000-0000-0000-000000000004"), // Authentication service
|
||||
MessageType: 0, // Request host name
|
||||
SentAt: time.Now(),
|
||||
Message: nil,
|
||||
}
|
||||
|
||||
// Set up the router
|
||||
router := information.Router
|
||||
|
||||
|
|
Reference in a new issue