Last active
March 7, 2019 16:23
-
-
Save Malinskiy/a624bc73218f9ba2fe0f0e29beb7d262 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DevicePoolActor(private val poolId: DevicePoolId, | |
private val configuration: Configuration, | |
analytics: Analytics, | |
tests: Collection<Test>, | |
private val progressReporter: ProgressReporter, | |
parent: Job, | |
context: CoroutineContext) : | |
Actor<DevicePoolMessage>(parent = parent, context = context) { | |
override suspend fun receive(msg: DevicePoolMessage) { | |
when (msg) { | |
is DevicePoolMessage.FromScheduler.AddDevice -> addDevice(msg.device) | |
is DevicePoolMessage.FromScheduler.RemoveDevice -> removeDevice(msg.device) | |
is DevicePoolMessage.FromScheduler.Terminate -> terminate() | |
is DevicePoolMessage.FromDevice.IsReady -> deviceReady(msg) | |
is DevicePoolMessage.FromDevice.CompletedTestBatch -> deviceCompleted(msg.device, msg.results) | |
is DevicePoolMessage.FromDevice.ReturnTestBatch -> deviceReturnedTestBatch(msg.device, msg.batch) | |
is DevicePoolMessage.FromQueue.Notify -> notifyDevices() | |
is DevicePoolMessage.FromQueue.Terminated -> onQueueTerminated() | |
is DevicePoolMessage.FromQueue.ExecuteBatch -> executeBatch(msg.device, msg.batch) | |
} | |
} | |
private suspend fun deviceCompleted(device: Device, results: TestBatchResults) { | |
queue.send(QueueMessage.Completed(device.toDeviceInfo(), results)) | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment