Skip to content

Instantly share code, notes, and snippets.

View sam-goodwin's full-sized avatar

sam sam-goodwin

View GitHub Profile
absl-py==2.1.0
aicsimageio==4.11.0
aioboto3==12.1.0
aiobotocore==2.8.0
aiofiles==23.2.1
aiohttp==3.9.3
aioitertools==0.11.0
aiosignal==1.3.1
alembic==1.13.1
aniso8601==9.0.1
from typing import Any, Optional, get_args, get_origin
import numpy as np
import pandas as pd
import pandera.typing as pdt
import pyarrow as pa
from pandera import DataFrameModel, Index, MultiIndex, dtypes
from pandera.engines import numpy_engine, pandas_engine
from pandera.engines.engine import _is_namedtuple, _is_typeddict
from pandera.typing.common import SeriesBase
@sam-goodwin
sam-goodwin / use-cases.md
Created January 11, 2024 22:55
function declaration decorator use-cases

Decorators on functions would be useful for frameworks that do basic reflection to infer configuration and bundle applications such as APIs, cloud functions, etc.

Examples

I think a good place to look at for examples is the Python ecosystem:

  1. Chalice uses decorators for wiring up function handlers to AWS resources
  2. Modal uses decorators to provision infrastructure and model the boundaries compute (different hosted functions)

Example 1: an @function() annotation marks a function as a hosted FaaS Function

Description

Instead of writing Velocity Templates or Amazon States Language, just write TypeScript functions and the Functionless compiler will automatically convert them to AppSync Resolver Pipelines and Step Function definitions. Enjoy the type-safety and expressiveness of TypeScript without Lambda Functions!

Describe your talk in as much detail as you desire

Functionless (https://github.com/sam-goodwin/functionless) is a Typescript Plugin that allows developers to write all of their infrastructure in native TypeScript, generating all the various configuration language like Amazon States Language, Velocity Templates, Event Bridge patterns (and more) without leaving TypeScript and without complicated DSLs.

The name, Functionless, comes from the concept of service-to-service integrations (colloquially referred to as "functionless") that are higher level than "serverless" integrations such as AWS Lambda Functions. The two examples I'll be discussing are AWS AppSync Resolvers and AWS Step Function's Ama

@sam-goodwin
sam-goodwin / asl.js
Created March 16, 2022 05:30
Step Function TS to ASL
{
StartAt: "State1",
States: {
State1: {
Catch: [
{
ErrorEquals: ["States.All"],
Next: "Throw",
},
],
@sam-goodwin
sam-goodwin / enumerable.ts
Last active August 24, 2019 04:59
Punchcard: processing SNS notifications with a Stream.
topic.stream().forEach(stack, 'ForEachNotification', {
handle: async (notification) => {
console.log(`sam's new blog is available!', notification);
}
});
@sam-goodwin
sam-goodwin / construct.ts
Created August 2, 2019 08:25
Constructs are syntax trees?
new Construct(scope, 'myConstruct');
// is a lot like:
function scope() {
const myConstruct = new Construct();
}
@sam-goodwin
sam-goodwin / handler.js
Created July 31, 2019 01:54
Vanilla CDK handler example
// manually create the AWS client, look up environment variables etc.
const AWS = require('aws-sdk');
const sns = new AWS.SNS();
const topicArn = process.env.TOPIC_ARN;
if (!topicArn) {
throw new Error('TOPIC_ARN must be defined');
}
@sam-goodwin
sam-goodwin / index.ts
Last active November 17, 2021 09:11
Lambda => SNS in punchcard
import cdk = require('@aws-cdk/core');
import { Function, Topic, string, integer, timestamp } from 'punchcard';
const app = new cdk.App();
export default app;
const stack = new cdk.Stack(app, 'my-stack');
// create a type-safe SNS Topic
const topic = new Topic(stack, 'Topic', {
type: struct({
@sam-goodwin
sam-goodwin / app.ts
Last active August 7, 2019 05:48
Vanilla CDK application example
import cdk = require('@aws-cdk/core');
import lambda = require('@aws-cdk/aws-lambda');
import sns = require('@aws-cdk/aws-sns');
import path = require('path');
const app = new cdk.App();
const stack = new cdk.Stack(app, 'my-stack');
const topic = new sns.Topic(stack, 'MyTopic');