public CommandJobsNancyModule(IMessageBus messageBus) : base("/commandjobs") { var data = new DataHelperClient(messageBus); Get["/{JobId}"] = _ => data.Get <CommandJob>(_.JobId.ToString()); }
public StitchesNancyModule(IMessageBus messageBus) : base("/stitches") { var data = new DataHelperClient(messageBus); // TODO: Method to get all StitchSummaries from the entire cluster (MasterModule) Get("/", _ => data.GetAll <StitchInstance>().ToList()); Get("/{StitchId}", _ => data.Get <StitchInstance>(_.StitchId.ToString())); Post <CommandResponse>("/{StitchId}/start", _ => messageBus.RequestWait <CommandRequest, CommandResponse>(new CommandRequest { Command = CommandType.StartStitchInstance, Target = _.StitchId.ToString() })); Post <CommandResponse>("/{StitchId}/stop", _ => messageBus.RequestWait <CommandRequest, CommandResponse>(new CommandRequest { Command = CommandType.StopStitchInstance, Target = _.StitchId.ToString() })); //Get["/{StitchId}/logs"] = _ => //{ // // Get last N log messages from the stitch // return null; //}; Get("/{StitchId}/resources", (Func <dynamic, StitchResourceUsage>)(_ => messageBus.RequestWait <StitchResourceUsageRequest, StitchResourceUsage>(new StitchResourceUsageRequest { StitchInstanceId = _.StitchId.ToString() }))); //Post["/{StitchId}/clone"] = _ => //{ // return messageBus.Request<CommandRequest, CommandResponse>(new CommandRequest // { // Command = CommandType.CloneStitchInstance, // Target = _.StitchId.ToString() // }); //}; Delete("/{StitchId}", _ => messageBus.RequestWait <CommandRequest, CommandResponse>(new CommandRequest { Command = CommandType.RemoveStitchInstance, Target = _.StitchId.ToString() })); Get <StitchHealthResponse>("/{StitchId}/status", _ => messageBus.RequestWait <StitchHealthRequest, StitchHealthResponse>(new StitchHealthRequest { StitchId = _.StitchId.ToString() })); //Post["/{StitchId}/moveto/{NodeId}"] = _ => //{ // // TODO: Move the stitch instance to the specified node // return null; //}; }
public ClusterNancyModule(IMessageBus messageBus) : base("/cluster") { var data = new DataHelperClient(messageBus); Get("/", _ => data.GetAll <NodeStatus>()); Get("/nodes/{NodeId}", (Func <dynamic, NodeStatus>)(_ => data.Get <NodeStatus>(_.NodeId.ToString()))); Get("/nodes/{NodeId}/stitches", _ => messageBus.RequestWait <StitchSummaryRequest, List <StitchSummary> >(new StitchSummaryRequest { NodeId = _.NodeId.ToString() })); Get("/nodes/{NodeId}/stitches/{StitchId}", _ => messageBus.RequestWait <StitchSummaryRequest, List <StitchSummary> >(new StitchSummaryRequest { NodeId = _.NodeId.ToString(), StitchId = _.StitchId.ToString() }).FirstOrDefault()); Get("/stitches", _ => messageBus.RequestWait <StitchSummaryRequest, List <StitchSummary> >(new StitchSummaryRequest())); Get("/stitchgroups/{GroupName}", _ => messageBus.RequestWait <StitchSummaryRequest, List <StitchSummary> >(new StitchSummaryRequest { StitchGroupName = _.GroupName.ToString() })); Post <PackageFileUploadResponse>("/stitchgroups/{GroupName}/upload", x => { var file = Request.Files.Single(); var request = new PackageFileUploadRequest { GroupName = new StitchGroupName(x.GroupName.ToString()), FileName = file.Name, Contents = file.Value, LocalOnly = false }; return(messageBus.RequestWait <PackageFileUploadRequest, PackageFileUploadResponse>(request)); }); Post <CreateInstanceResponse>("/stitchgroups/{GroupName}/createinstance", x => { var request = this.Bind <CreateInstanceRequest>(); request.GroupName = new StitchGroupName(x.GroupName.ToString()); request.LocalOnly = false; return(messageBus.RequestWait <CreateInstanceRequest, CreateInstanceResponse>(request)); }); Post <CommandResponse>("/stitchgroups/{GroupName}/stopall", _ => messageBus.RequestWait <CommandRequest, CommandResponse>(new CommandRequest { Command = CommandType.StopStitchGroup, Target = _.GroupName.ToString() })); Post <CommandResponse>("/stitchgroups/{GroupName}/startall", _ => messageBus.RequestWait <CommandRequest, CommandResponse>(new CommandRequest { Command = CommandType.StartStitchGroup, Target = _.GroupName.ToString() })); //Post("/stitchgroups/{GroupName}/stopoldversions", _ => //{ // // TODO: Stop all instances in the version group which are older than the group // // specified // return null; //}); //Post("/stitchgroups/{GroupName}/rebalance", _ => //{ // // TODO: Rebalance all instances in the group across the cluster // return null; //}); }