This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/s3/s3manager" | |
"github.com/aws/aws-sdk-go/service/sqs" | |
"os" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import timeout_decorator | |
@timeout_decorator.timeout(5) | |
def mytest(): | |
print("Start") | |
for i in range(1,10): | |
time.sleep(1) | |
print("{} seconds have passed".format(i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(n): | |
a, b = 0, 1 | |
for _ in range(n): | |
yield a | |
a, b = b, a + b | |
k = fib(10) | |
>>> next(k) | |
0 | |
>>> next(k) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"net/http" | |
"github.com/subzero112233/golang-twirp/rpc/stats" | |
"github.com/twitchtv/twirp" | |
"google.golang.org/protobuf/types/known/timestamppb" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package twirphandler | |
import ( | |
"context" | |
"net/http" | |
"time" | |
"github.com/subzero112233/golang-twirp/entity" | |
"github.com/subzero112233/golang-twirp/rpc/stats" | |
"github.com/subzero112233/golang-twirp/usecase/playerstats" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'player_name:"Jae Crowder"' \ | |
| protoc --encode stats.GetStatsRequest ./rpc/stats/stats.proto \ | |
| curl -s --request POST \ | |
--header "Content-Type: application/protobuf" \ | |
--data-binary @- \ | |
http://localhost:8000/twirp/stats.StatsService/GetStats \ | |
| protoc --decode stats.GetStatsResponse ./rpc/stats/stats.proto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
import "google/protobuf/timestamp.proto"; | |
option go_package = "./rpc/stats"; | |
package stats; | |
service StatsService { | |
rpc AddStats(AddStatsRequest) returns (AddStatsResponse); | |
rpc GetStats(GetStatsRequest) returns (GetStatsResponse); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package handler | |
import ( | |
"aws-golang-lambda/api/middleware" | |
"aws-golang-lambda/entity" | |
"aws-golang-lambda/usecase/users" | |
"fmt" | |
"github.com/gin-gonic/gin" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package users | |
import ( | |
"github.com/rs/zerolog" | |
) | |
type Service struct { | |
Repository Repository | |
Logger *zerolog.Logger | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package entity | |
type User struct { | |
Address string `json:"address"` | |
FirstName string `json:"first_name"` | |
LastName string `json:"last_name"` | |
Password string `json:"password"` | |
Username string `json:"username"` | |
} |
NewerOlder