As the user base grew to 100,000+, the existing permission checks became a bottleneck, slowing down resource access across the CRM.
Go • gRPC • RabbitMQ • PostgreSQL • Redis
// CheckPermission implements the Zanzibar check API
func (s *Server) CheckPermission(ctx context.Context, req *pb.CheckRequest) (*pb.CheckResponse, error) {
// Check cache first
if allowed, hit := s.cache.Get(req); hit {
return &pb.CheckResponse{Allowed: allowed}, nil
}
// Traverse the relation graph
allowed, err := s.graph.Traverse(ctx, req.Subject, req.Relation, req.Object)
if err != nil {
return nil, err
}
// Async cache update
go s.cache.Set(req, allowed)
return &pb.CheckResponse{Allowed: allowed}, nil
}