Exemple #1
0
 public RunlyJobQueue(
     IOptionsSnapshot <AppOptions> appOpts,
     IOptionsSnapshot <RunlyOptions> runlyOpts,
     IRunClient runs
     )
 {
     this.appOpts   = appOpts.Value;
     this.runlyOpts = runlyOpts.Value;
     this.runs      = runs;
 }
Exemple #2
0
        /// <summary>
        /// Enqueues a new run with the stored config template in the <paramref name="organization"/> and <paramref name="environment"/>.
        /// Overrides parameters in the config template with values found on <paramref name="overrides"/>.
        /// </summary>
        /// <param name="client">The API client to use.</param>
        /// <param name="organization">The organization in which the <paramref name="environment"/> can be found.</param>
        /// <param name="environment">The environment to enqueue a new run in.</param>
        /// <param name="template">The name of the config template to use for the new run.</param>
        /// <param name="overrides">When provided, will override parameters in the config template.</param>
        /// <param name="scheduled">When true, will count the enqueued run as an occurence of the config template's schedule, affecting the next occurence of the schedule.</param>
        /// <returns>A newly enqueued <see cref="Run"/>.</returns>
        public static Task <Run> EnqueueFromTemplate(this IRunClient client, string organization, string environment, string template, object overrides = null, bool scheduled = false)
        {
            var jobj = JObject.FromObject(overrides ?? new { }, ConfigWriter.Serializer);

            jobj["template"]  = template;
            jobj["scheduled"] = scheduled;
            string json = jobj.ToString();

            return(client.Enqueue(organization, environment, json));
        }
Exemple #3
0
 public static Task <Run> Enqueue(this IRunClient client, string organization, string environment, string jobType, string version = null, string package = null)
 {
     return(client.Enqueue(organization, environment, new Config
     {
         Job = new JobConfig
         {
             Type = jobType,
             Version = version,
             Package = package
         }
     }));
 }
Exemple #4
0
 public static Task <Run> Enqueue <TJob>(this IRunClient client, string organization, string environment, string version = null, string package = null)
     where TJob : class
 {
     return(client.Enqueue(organization, environment, new Config
     {
         Job = new JobConfig
         {
             Type = typeof(TJob).FullName,
             Version = version,
             Package = package
         }
     }));
 }
Exemple #5
0
        public static Task <Run> Enqueue <TConfig>(this IRunClient client, string organization, string environment, string jobType, TConfig config = null, string version = null, string package = null)
            where TConfig : Config
        {
            Config cfg = config ?? new Config();

            cfg.Job = new JobConfig
            {
                Type    = jobType,
                Version = version,
                Package = package
            };

            return(client.Enqueue(organization, environment, cfg));
        }
Exemple #6
0
 /// <summary>
 /// Enqueues a new run with the <paramref name="config"/> in the <paramref name="organization"/> and <paramref name="environment"/>.
 /// </summary>
 /// <param name="client">The API client to use.</param>
 /// <param name="organization">The organization in which the <paramref name="environment"/> can be found.</param>
 /// <param name="environment">The environment to enqueue a new run in.</param>
 /// <param name="config">The <see cref="Config"/> for the new run.</param>
 /// <returns>A newly enqueued <see cref="Run"/>.</returns>
 public static Task <Run> Enqueue(this IRunClient client, string organization, string environment, Config config) =>
 client.Enqueue(organization, environment, ConfigWriter.ToJson(config));
Exemple #7
0
 /// <summary>
 /// Gets the <see cref="Config"/> for the <paramref name="runId"/> specified.
 /// </summary>
 /// <typeparam name="TConfig">The type of config to get.</typeparam>
 /// <param name="client">The API client to use.</param>
 /// <param name="organization">The organization that the run exists in.</param>
 /// <param name="runId">The ID of the run to get the config for.</param>
 /// <returns>A <see cref="Config"/> of type <typeparamref name="TConfig"/>.</returns>
 public static async Task <TConfig> GetConfig <TConfig>(this IRunClient client, string organization, Guid runId) where TConfig : Config =>
 JsonConvert.DeserializeObject <TConfig>(await client.GetConfig(organization, runId), ConfigWriter.Settings);