Skip to content

Commit

Permalink
applied key for elevator
Browse files Browse the repository at this point in the history
  • Loading branch information
yahya077 authored and yahya.hindioglu committed Mar 29, 2024
1 parent 3ba7136 commit 40403a5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions elevator/elevator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/WEG-Technology/room/store"
"gopkg.in/yaml.v3"
"os"
"slices"
"sync"
"time"
)
Expand All @@ -32,7 +33,7 @@ func marshalJson(config IntegrationConfig) (jsonData []byte, err error) {

type IElevatorEngine interface {
Execute(roomKey, requestKey string) (room.Response, error)
ExecuteConcurrent(concurrentKey string) map[string]room.Response
ExecuteConcurrent(concurrentKey string, appliedRooms ...string) map[string]room.Response
WarmUp() IElevatorEngine
PutBodyParser(roomKey, requestKey string, bodyParser room.IBodyParser) IElevatorEngine
PutQuery(roomKey, requestKey string, authStrategy room.IQuery) IElevatorEngine
Expand Down Expand Up @@ -82,7 +83,7 @@ func (c *RoomResponseContainer) PutResponse(key string, response room.Response)
c.Responses[key] = response
}

func (e *ElevatorEngine) ExecuteConcurrent(concurrentKey string) map[string]room.Response {
func (e *ElevatorEngine) ExecuteConcurrent(concurrentKey string, appliedRooms ...string) map[string]room.Response {
e.Segment = segment.StartSegmentNow()
defer e.Segment.End()

Expand All @@ -94,7 +95,7 @@ func (e *ElevatorEngine) ExecuteConcurrent(concurrentKey string) map[string]room

for roomKey, configRoom := range e.elevator.Config.Flat.Rooms {
for requestKey, req := range configRoom.Requests {
if concurrentKey == req.ConcurrentKey {
if ((len(appliedRooms) > 0 && slices.Contains(appliedRooms, roomKey)) || len(appliedRooms) == 0) && concurrentKey == req.ConcurrentKey {
wg.Add(1)
go func(a, b string) {
//TODO handle errors
Expand Down

0 comments on commit 40403a5

Please sign in to comment.