Example #1
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));
        }
Example #2
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
         }
     }));
 }
Example #3
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
         }
     }));
 }
Example #4
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));
        }
Example #5
0
        public async Task <Guid> SendPendingInvitations()
        {
            // this method just abstracts the specifics of queueing a job away from the app
            var run = await runs.Enqueue <InvitationEmailer, InvitationEmailerConfig>(
                runlyOpts.Org,
                runlyOpts.Env,
                new InvitationEmailerConfig
            {
                ConnectionString = appOpts.ConnectionString,
                Execution        = new ExecutionConfig
                {
                    // let's send 50 emails at a time
                    ParallelTaskCount = 50,

                    // don't stop the job unless we get over 100 failed items
                    ItemFailureCountToStopJob = 100
                }
            }
                );

            return(run.Id);
        }
Example #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));