Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Goサーバをあえて不安定にするパッケージを作った話

 Goサーバをあえて不安定にするパッケージを作った話

Go(Un)Conference(Goあんこ)LT大会 5kg

https://gounconference.connpass.com/event/112942/

Hazumi Ichijo

January 31, 2019
Tweet

More Decks by Hazumi Ichijo

Other Decks in Programming

Transcript

  1. ©2018 Wantedly, Inc. Ͳ͏͍ͬͨৼΔ෣͍Λ͢΂͖͔ https://engineering.linkedin.com/blog/2018/05/linkedout--a-request-level-failure-injection-framework -JOLFEJOͷ'BJMVSF*OKFDUJPO'SBNFXPSLͰ͸ w &SSPS w %FMBZ

    w 5JNFPVU ͷͭΛೖΕ͍ͯΔ ͦͷ͏ͪɺ&SSPSɾ5JNFPVU͕͋Ε͹ࢼͤͦ͏ɻ ߋʹɺͦ͏͍ͬͨৼΔ෣͍͸ϥϯμϜʹى͖ΔΑ͏ʹ͍ͨ͠ αʔϏεΛ6OJY5JNF͕/ͰׂΓ੾ΕΔͱ͖ΞϗʹͳΔΑ͏ʹ͢Ε͹ྑ͛͞
  2. ©2018 Wantedly, Inc. package main import ( "fmt" "net/http" "github.com/rerost/unstable/uhttp"

    ) func main() { http.Handle("/", uhttp.WithUnstable(handler)) if err := http.ListenAndServe(":3000", nil); err != nil { fmt.Println(err) } } func handler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Sample")) }
  3. ©2018 Wantedly, Inc. package main import ( "context" "log" "net"

    "github.com/golang/protobuf/ptypes/empty" api_pb "github.com/rerost/unstable/example/grpc/server/api" "github.com/rerost/unstable/ugrpc" "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) type server struct{} func (s *server) GetSample(ctx context.Context, req *empty.Empty) (*api_pb.GetSampleResponse, error) { return &api_pb.GetSampleResponse{Message: "Sample"}, nil } func main() { l, err := net.Listen("tcp", ":5000") if err != nil { log.Fatalf("Failed to listen: %v", err) } s := grpc.NewServer( grpc.UnaryInterceptor(ugrpc.UnstableUnaryServerInterceptor()), ) api_pb.RegisterSampleServiceServer(s, &server{}) reflection.Register(s) if err := s.Serve(l); err != nil { log.Fatalf("Failed to serve: %v", err) } }