https://github.com/beeceej/inflight
Abstracts away Retrieving and Writing Data to S3
https://github.com/beeceej/inflight
aws aws-lambda go golang stepfunctions
Last synced: 10 months ago
JSON representation
Abstracts away Retrieving and Writing Data to S3
- Host: GitHub
- URL: https://github.com/beeceej/inflight
- Owner: beeceej
- License: mit
- Created: 2019-01-06T23:46:44.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-30T21:26:50.000Z (over 5 years ago)
- Last Synced: 2025-01-28T17:22:31.851Z (11 months ago)
- Topics: aws, aws-lambda, go, golang, stepfunctions
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Inflight
[](https://travis-ci.org/beeceej/inflight)
[](https://codecov.io/gh/beeceej/inflight)
[](https://goreportcard.com/report/github.com/beeceej/inflight)
Inflight is a simple package which abstracts away writing to and from S3. It handles retries (with an exponential back off algorithm), and can be configured to write to any S3 bucket.
An Example of where this package could be useful is when the data you're working with is too large to be manually passed through. This provides a simple way to ship references to data between functions in a state machine.
Example usage.
## Lambda 1:
```go
package main
var infl *inflight.Infight
func init() {
bucket := os.Getenv("INFLIGHT_BUCKET")
path := os.Getenv("INFLIGHT_PATH")
s3 := //an s3 client
infl = inflight.NewInflight(Bucket(bucket), KeyPath(path), s3)
}
func handler(event interface{}) *inflight.Ref {
dataWhichIsOverTheAwsLimit := bytes.NewReader(...)
return infl.Write(dataWhichIsOverTheAwsLimit)
}
func main() {
lambda.Start(handler)
}
```
## Lambda 2:
```go
package main
var infl *inflight.Infight
func init() {
bucket := os.Getenv("INFLIGHT_BUCKET")
path := os.Getenv("INFLIGHT_PATH")
s3 := //an s3 client
infl = inflight.NewInflight(Bucket(bucket), KeyPath(path), s3)
}
func handler(event *inflight.Ref) *inflight.Ref {
b, err := infl.Get(event.Object)
// ...
// Do Some stuff with your data
// ...
dataWhichIsOverTheAwsLimit := doSomeStuffWithYourData(b)
// Write the data back
return infl.Write(dataWhichIsOverTheAwsLimit)
}
func main() {
lambda.Start(handler)
}
```