ISM rewrite part 8
This commit is contained in:
parent
b82928e820
commit
f3cfc9e170
15
main.go
15
main.go
|
@ -171,11 +171,12 @@ func (s *ServiceInitializationInformation) SendISMessage(forService uuid.UUID, m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InterServiceMessage) Respond(messageType MessageCode, message any, information ServiceInitializationInformation) {
|
func (s *InterServiceMessage) Respond(messageType MessageCode, message any, information ServiceInitializationInformation) {
|
||||||
s.ServiceID, s.ForServiceID = s.ForServiceID, s.ServiceID
|
n := *s
|
||||||
s.MessageType = messageType
|
n.ServiceID, n.ForServiceID = n.ForServiceID, n.ServiceID
|
||||||
s.Message = message
|
n.MessageType = messageType
|
||||||
s.SentAt = time.Now()
|
n.Message = message
|
||||||
information.Outbox <- *s
|
n.SentAt = time.Now()
|
||||||
|
information.Outbox <- n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ServiceInitializationInformation) SendAndAwaitISMessage(forService uuid.UUID, messageType MessageCode, message any, timeout time.Duration) (InterServiceMessage, error) {
|
func (s *ServiceInitializationInformation) SendAndAwaitISMessage(forService uuid.UUID, messageType MessageCode, message any, timeout time.Duration) (InterServiceMessage, error) {
|
||||||
|
@ -183,12 +184,14 @@ func (s *ServiceInitializationInformation) SendAndAwaitISMessage(forService uuid
|
||||||
return AwaitISMessage(id, timeout)
|
return AwaitISMessage(id, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var databaseService = uuid.MustParse("00000000-0000-0000-0000-000000000001")
|
||||||
|
|
||||||
func (s *ServiceInitializationInformation) GetDatabase() (Database, error) {
|
func (s *ServiceInitializationInformation) GetDatabase() (Database, error) {
|
||||||
if !ispStarted {
|
if !ispStarted {
|
||||||
go s.StartISProcessor()
|
go s.StartISProcessor()
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := s.SendAndAwaitISMessage(uuid.Nil, 0, nil, 5*time.Second)
|
response, err := s.SendAndAwaitISMessage(databaseService, 0, nil, 5*time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Database{}, err
|
return Database{}, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue