async void OnJobRequestMessage(string clientId, JobRequestMsg msg)
        {
            // should we dispatch a new job for this judger?
            using var reqLock = await connectionLock.LockAsync();

            if (connections.TryGetValue(clientId, out var conn))
            {
                conn.CanAcceptNewTask = msg.ActiveTaskCount > 0;
                conn.ActiveTaskCount  = msg.ActiveTaskCount;

                reqLock.Dispose();

                var dispatchedCount = await TryDispatchJobFromDatabase(conn, msg.RequestForNewTask, msg.MessageId);

                if (dispatchedCount > 0)
                {
                    logger.LogInformation("Sent {1} jobs to {0}", dispatchedCount, clientId);
                }
                else
                {
                    logger.LogDebug("Sent no jobs to {0}", dispatchedCount, clientId);
                }
            }
        }
Beispiel #2
0
        public Job CreateJob(Uri uri, JobRequestMsg msg)
        {
            string data = transport.doPOST(uri, JSON.Serialize(msg));

            return(JSON.Deserialise <Job>(data));
        }