Skip to content

v1.3.0 Silver Crocodile

Compare
Choose a tag to compare
@petomalina petomalina released this 08 Apr 15:24
· 13 commits to master since this release

This release adds a new API for running the multiplexer with a graceful shutdown.

ctx, done := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
// ...

srv, err := multiplexer.NewServer(os.Getenv("PORT"), time.Second*5)
// ...

err = srv.ServeHTTPHandler(ctx,
	multiplexer.Make(nil,
		// filters all application/grpc messages into the grpc server
		multiplexer.GRPCHandler(grpcServer),
		// defaults all other messages into the http multiplexer
		multiplexer.HTTPHandler(gwmux),
	))

The example above creates a new context for SIGINT and SIGTERM and passes that to the srv.ServeHTTPHandler method above the multiplexer.Server type. Once this context is cancelled by the system, it automatically shuts down the h2c server of the handler.