
Product
A Fresh Look for the Socket Dashboard
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
github.com/rerost/unstable
Make unstable http/gRPC server
I think there are multiple types of instability.
This package support three unstable.
You can configure "unstable" by unstable.json
.
Like,
{
"interval": 1,
"slow_response_option": {
"enable": true,
"time": 500
},
"server_error_option": {
"enable": true
}
}
interval
(seconds): When the unix time(sencods) is be divisable by interval
, then return slow response
or server error
. When 0
, then disable this package.slow_response_option
: Control repsonse time.
enable
: When true, then response time will take more than time
time
(milliseconds): Response time will take more than time
server_error_option
: Control server error.
enable
: When true, then return server errorPseudocode
if interval != 0 && UnixTime%interval {
if slow_response_option.enable {
sleep(slow_response_option.time)
}
if server_error_option.enable {
raise_server_error()
}
}
This package support only http
and gRPC
server.
See example https://github.com/rerost/unstable/tree/master/example .
$ go get github.com/rerost/unstable/uhttp
server.go
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"))
}
$ go get github.com/rerost/unstable/ugrpc
server.go
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)
}
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We’ve redesigned the Socket dashboard with simpler navigation, less visual clutter, and a cleaner UI that highlights what really matters.
Industry Insights
Terry O’Daniel, Head of Security at Amplitude, shares insights on building high-impact security teams, aligning with engineering, and why AI gives defenders a fighting chance.
Security News
MCP spec updated with structured tool output, stronger OAuth 2.1 security, resource indicators, and protocol cleanups for safer, more reliable AI workflows.