-
Notifications
You must be signed in to change notification settings - Fork 9
/
service.go
38 lines (30 loc) · 963 Bytes
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package volume
import (
"context"
"temporal_microservices"
"temporal_microservices/domain"
)
var ParallelepipedVolumeActivityName = domain.GetActivityName(Service{}.CalculateParallelepipedVolume)
type Parallelepiped struct {
ID string
Length float64
Width float64
Height float64
}
type Service struct{}
type CalculateParallelepipedVolumeRequest struct {
Parallelepipeds []Parallelepiped
}
type CalculateParallelepipedVolumeResponse struct {
Volumes map[string]float64
}
func (s Service) CalculateParallelepipedVolume(ctx context.Context, req CalculateParallelepipedVolumeRequest) (resp CalculateParallelepipedVolumeResponse, err error) {
heartbeat := domain.StartHeartbeat(ctx, temporal_microservices.HeartbeatIntervalSec)
defer heartbeat.Stop()
resp.Volumes = make(map[string]float64, len(req.Parallelepipeds))
for _, p := range req.Parallelepipeds {
volume := p.Width * p.Length * p.Height
resp.Volumes[p.ID] = volume
}
return
}