Exemplo n.º 1
0
 public ToolRunServer(RunServerOptions options, ServerConfiguration config, IKernel kernel, IGluonHostPool hostPool)
 {
     Options  = options;
     Config   = config;
     Kernel   = kernel;
     HostPool = hostPool;
 }
Exemplo n.º 2
0
 public ToolRunServer(RunServerOptions options, ServerConfiguration config, IKernel kernel, IGluonHostPool hostPool)
 {
     this.Options  = options;
     this.Config   = config;
     this.Kernel   = kernel;
     this.HostPool = hostPool;
 }
Exemplo n.º 3
0
        public AdminTasksController(IDAFactory daFactory, JWTFactory jwt, IGluonHostPool hostPool) : base("/admin")
        {
            JWTTokenAuthentication.Enable(this, jwt);

            Get["/tasks"] = _ =>
            {
                this.DemandAdmin();

                using (var da = daFactory.Get)
                {
                    var offset = Request.Query["offset"];
                    var limit  = Request.Query["limit"];

                    if (offset == null)
                    {
                        offset = 0;
                    }
                    if (limit == null)
                    {
                        limit = 20;
                    }

                    if (limit > 100)
                    {
                        limit = 100;
                    }

                    var result = da.Tasks.All((int)offset, (int)limit);
                    return(Response.AsPagedList(result));
                }
            };

            Post["/tasks/request"] = x =>
            {
                var task = this.Bind <TaskRequest>();

                var taskServer = hostPool.GetByRole(Database.DA.Hosts.DbHostRole.task).FirstOrDefault();
                if (taskServer == null)
                {
                    return(Response.AsJson(-1));
                }
                else
                {
                    try {
                        var id = taskServer.Call(new RequestTask()
                        {
                            TaskType      = task.task_type.ToString(),
                            ParameterJson = JsonConvert.SerializeObject(task.parameter),
                            ShardId       = (task.shard_id == null || !task.shard_id.HasValue) ? -1 : task.shard_id.Value
                        }).Result;
                        return(Response.AsJson(id));
                    }catch (Exception ex)
                    {
                        return(Response.AsJson(-1));
                    }
                }
            };
        }
Exemplo n.º 4
0
        public AdminHostsController(IDAFactory daFactory, JWTFactory jwt, IGluonHostPool hostPool) : base("/admin")
        {
            JWTTokenAuthentication.Enable(this, jwt);

            this.Get["/hosts"] = _ =>
            {
                this.DemandAdmin();
                var hosts = hostPool.GetAll();

                return(Response.AsJson(hosts.Select(x => new {
                    role = x.Role,
                    call_sign = x.CallSign,
                    internal_host = x.InternalHost,
                    public_host = x.PublicHost,
                    connected = x.Connected,
                    time_boot = x.BootTime
                })));
            };
        }
Exemplo n.º 5
0
 public GluonAuthenticationHandler(ISessions sessions, ServerConfiguration config, IGluonHostPool hostPool)
 {
     this.Sessions = sessions;
     this.Secret   = config.Secret;
     this.HostPool = hostPool;
 }
Exemplo n.º 6
0
 public BirthdayGiftTask(IDAFactory DAFactory, TaskTuning tuning, IGluonHostPool hostPool)
 {
     this.DAFactory = DAFactory;
     this.Tuning    = tuning;
     this.HostPool  = hostPool;
 }
Exemplo n.º 7
0
 public NeighborhoodsTask(IDAFactory DAFactory, IGluonHostPool hostPool)
 {
     this.DAFactory = DAFactory;
     this.HostPool  = hostPool;
 }
Exemplo n.º 8
0
 public JobBalanceTask(IDAFactory DAFactory, TaskTuning tuning, IGluonHostPool hosts)
 {
     this.DAFactory = DAFactory;
     this.Tuning    = tuning;
     this.HostPool  = hosts;
 }