Skip to content

Commit

Permalink
Start documenting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
msdundar committed Jun 13, 2021
1 parent 12a1b07 commit 6e4c604
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lambda_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"github.com/aws/aws-sdk-go/service/lambda"
)

// LambdaClient initializes a new lambda client that can be used in lambda
// actions. Endpoint will be set to a localstack endpoint when running tests,
// otherwise it will use the default AWS location.
func LambdaClient(region string) *lambda.Lambda {
return lambda.New(
session.Must(session.NewSessionWithOptions(session.Options{
Expand Down
2 changes: 2 additions & 0 deletions lambda_full_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"github.com/aws/aws-sdk-go/service/lambda"
)

// FullRollOut resets the routing config and shifts whole traffic from the
// new version to the alias. It returns a LambdaUpdateAliasResponse struct.
func FullRollOut(
client *lambda.Lambda,
lambdaPackage LambdaPackage,
Expand Down
8 changes: 8 additions & 0 deletions lambda_gradual_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import (
"github.com/aws/aws-sdk-go/service/lambda"
)

// GradualRollOut is the main function for gradual rollouts. It takes a version.
// argument that refers to the new version that traffic is going to be shifted
// for. traffic stands for the amount of traffic to be shifted on each step. For
// example, 0.05 stands for 5%, and 20 steps is going to be required for a full
// rollout (100/5=20). runs argument stands for number of health checks you
// would like to run on each step. sleep is number of seconds to sleep on each
// step. And finally, payload can be used as a request body to send when running
// health checks.
func GradualRollOut(
client *lambda.Lambda,
lambdaPackage LambdaPackage,
Expand Down
3 changes: 3 additions & 0 deletions lambda_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type HealthCheckResponse struct {
Body string `json:"body"`
}

// HealthChecks runs health checks on a given lambda version or alias. It can
// take a payload argument that be used to satisfy request body expectations
// of a lambda.
func HealthCheck(
client *lambda.Lambda,
lambdaPackage LambdaPackage,
Expand Down
8 changes: 8 additions & 0 deletions lambda_package.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package kanarya

// A LambdaBucket is used to reflect structure of an AWS S3 bucket that is used
// to store lambda functions.
type LambdaBucket struct {
Name string
Key string
}

// A LambdaFunction is used to reflect structure of an AWS Lambda function.
type LambdaFunction struct {
Name string
}

// A LambdaAlias is used to reflect structure of a lambda alias. Lambda aliases
// are used in traffic shifthing and gradual deployments.
type LambdaAlias struct {
Name string
}

// A LambdaPackage is an internal representation of a lambda function that can
// be deployed gradually. LambdaPackage is a composite struct made of other
// structs.
type LambdaPackage struct {
Location string
Function LambdaFunction
Expand Down

0 comments on commit 6e4c604

Please sign in to comment.