-
Notifications
You must be signed in to change notification settings - Fork 2
Activity registration
In Amazon SWF you register all your workflows and activities under a domain. For information on how domain is handled by Guflow, please look at workflow section.
For a workflow to schedule the activity it needs to be registered with Amazon SWF. You can register a activity with Amazon SWF using either of following approach-
- Login to Amazon Console and register it from SWF dashboard
- Or use Guflow API
Advantage of using the Guflow approach is that it only register the activity if it is not already registered and it can prove helpful when you use different Amazon SWF configuration in different stages of your build pipeline.
To register the activity with Amazon SWF Guflow.Domain class provides couple of overloaded methods. One of the following overloaded method will register the activity with Amazon SWF by reading the properties of ActivityDescriptionAttribute for DownloadActivity:
await domain.RegisterActivityAsync<DownloadActivity>();
Following example shows how you can use ActivityDescriptionAttribute to provide workflow registration details:
[ActivityDescription("1.0", Name="DownloadActivit", Description="Will download the videos from S3 bucket",
DefaultTaskListName="FastList", DefaultChildPolicy=ChildPolicy.Abandon)]
public class TranscodeWorkflow : Workflow
{
}
Note: While registering the activity with Amazon SWF, you have the option to provide different activity properties such as: "Name", "Description", "DefaultTaskListName" etc. These properties are must when you're scheduling the activity but you have the flexibility to supply them at registration time or when you are about to schedule the activity from workflow.
ActivityDescriptionAttribute will be limiting if you want to change its attribute in different environments. You can provide ActivityDescription dynamically as shown below
public class DownloadActivity: Activity
{
public static ActivityDescription Description=>
new ActivityDescription("1.0")
{
Name = "test",
Description = "desc",
DefaultTaskListName = "tname",
DefaultExecutionStartToCloseTimeout = TimeSpan.FromSeconds(10),
DefaultTaskStartToCloseTimeout = TimeSpan.FromSeconds(9),
DefaultChildPolicy= "policy",
DefaultLambdaRole ="lambdarole",
DefaultTaskPriority =1
};
}
Guflow will look for any static method (without any arguments)/property with ActivityDescription as return type and returned ActivityDescription will take priority over ActivityDescriptionAttribute.
If you need to access config file/database to build ActivityDescription then it is probably best to create it with some factory but it is entirely up to you on how you layout the code.
public class DownloadActivity: Activity
{
public static ActivityDescription=>
DescriptionFactory.DownloadActivityDescription();
}
Guflow
- Prerequisite
- Installation
-
Workflows
- Creating first workflow
- Registration
- Hosting
- Start workflow
- Schedule activities
- Schedule timers
- Schedule lambda function
- Schedule child workflows
- Lambda functions vs activities
- Workflow input
- Workflow actions
- Signals
- Workflow branches
- Deflow algorithm
- Workflow events
- Query APIs
- Custom polling strategy
- Things to take care of
- Activites
- Unit testing
- Performance & scalability
- Error handling
- Logging
- Debugging
- Tutorial
- Release notes