Skip to content

Instantly share code, notes, and snippets.

View thomaspoignant's full-sized avatar

Thomas Poignant thomaspoignant

View GitHub Profile
var chiLambda *chiadapter.ChiLambda
// handler is the function called by the lambda.
func handler(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
return chiLambda.ProxyWithContext(ctx, req)
}
// main is called when a new lambda starts, so don't
// expect to have something done for every query here.
func main() {
/**
* buildAndInstallGOLambda build the code and create the lambda
* @param id - CDK id for this lambda
* @param lambdaPath - Location of the code
* @param handler - name of the handler to call for this lambda
*/
buildAndInstallGOLambda(id: string, lambdaPath: string, handler: string): lambda.Function {
const environment = {
CGO_ENABLED: '0',
GOOS: 'linux',
/**
* createApiGatewayForLambda is creating a Rest API Gateway to access to your lambda function
* @param id - CDK id for this lambda
* @param handler - Lambda function to call
* @param description - Description of this endpoint
*/
createApiGatewayForLambda(id: string, handler: lambda.Function, description: string): LambdaRestApi{
return new LambdaRestApi(this, id, {
handler,
description
@thomaspoignant
thomaspoignant / pipeline.yaml
Created April 16, 2021 09:22
Pipeline configuration example
root: handler1_name
steps:
handler1_name:
type: handlerImpl1
next: handler2_name
handler2_name:
type: handlerImpl2
@thomaspoignant
thomaspoignant / pipeline.go
Last active February 7, 2023 15:10
Building a pipeline system in golang
package main
import (
"fmt"
"gopkg.in/yaml.v3"
"io"
"net/http"
)
// PipelineConfig is the representation of a pipeline in the configuration.

Keybase proof

I hereby claim:

  • I am thomaspoignant on github.
  • I am thomaspoignant (https://keybase.io/thomaspoignant) on keybase.
  • I have a public key ASDtkh-5twLIZx6Ip4W7QaueOa06almAgIuHeoc3DToyXgo

To claim this, I am signing this object:

docker run --rm -it -p 4566:4566 -p 4571:4571 localstack/localstack
# create topic
aws --region=eu-west-1 --endpoint-url=http://localhost:4566 sns create-topic --name responseTopic
# list topic and get ARN
aws --region=eu-west-1 --endpoint-url=http://localhost:4566 sns list-topics
# create SQS queue
aws --region=eu-west-1 --endpoint-url=http://localhost:4566 sqs create-queue --queue-name test-queue
@thomaspoignant
thomaspoignant / example.go
Created October 11, 2021 08:12
Go-feature-flag example
/**
test-flag:
rule: (role eq "devops") and (env eq "pro") and (key eq "example@test.com") and (company eq "go-feature-flag")
percentage: 100
true: true
false: false
default: false
*/
user := ffuser.NewUserBuilder("example@test.com").
@thomaspoignant
thomaspoignant / sort_pipeline_example.py
Created November 8, 2021 13:48
An example to sort a list of jobs depending on their depends.
from typing import Dict, List, Optional
import networkx as nx
def main():
stages = {
"Lint": [],
"Test": [],
"Coverage": ["Test"],
"Docs": ["Coverage", "Lint"],
# sort the stages
out_degree_map = {v: d for v, d in g.out_degree() if d > 0}
zero_out_degree = [v for v, d in g.out_degree() if d == 0]
while zero_out_degree:
yield zero_out_degree
new_zero_out_degree = []
for v in zero_out_degree:
for child, _ in g.in_edges(v):
out_degree_map[child] -= 1
if not out_degree_map[child]: