Skip to content

An API for setting microservice polling for against AWS SFN workflows.

License

Notifications You must be signed in to change notification settings

eltorocorp/sfn-poller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sfn-poller

An API for setting up microservice polling against AWS SFN workflows.

example

Setting up a service to poll a state machine for work.

import (
	"context"

	"github.com/aws/aws-sdk-go/aws/client"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/sfn"
	"github.com/eltorocorp/sfn-poller/sfnpoller"
	"github.com/eltorocorp/sfn-poller/sfnpoller/pollable"
        somemicroservice "github.com/coolsoftwareprovider/somerepository"
)

func main() {
	env := environment.MustGetArgumentsFromEnvVars() // <- basically some method that resolves environment variables into a struct
	sfnAPI := sfn.New(getSession())
	poller := sfnpoller.
		New().
		RegisterTask(pollable.NewTask(somemicroservice.Handle, env.ActivityARN, env.WorkerName, env.Timeout, sfnAPI)).
		BeginPolling(context.Background())
	<-poller.Done()
}

func getSession() client.ConfigProvider {
	return session.Must(session.NewSessionWithOptions(session.Options{
		SharedConfigState: session.SharedConfigEnable,
	}))
}

About

An API for setting microservice polling for against AWS SFN workflows.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages