Skip to content

Instantly share code, notes, and snippets.

View active_record_with_connection_interceptor.rb
class ActiveRecordWithConnectionInterceptor < ::GRPC::ServerInterceptor
def request_response(**)
# ref:
::ActiveRecord::Base.connection_pool.with_connection do
alias_method :server_streamer, :request_response
alias_method :client_streamer, :request_response
sat0yu / bloomfilter.go
Created Sep 23, 2019
A BloomFilter implementation
View bloomfilter.go
package main
import (
sat0yu / minhash.go
Created Sep 15, 2019
A MinHash implementation in go
View minhash.go
package main
import (
const DIM = 26 // |{'a', ..., 'z'}| = 26
sat0yu / interceptor.go
Created Jul 7, 2019
View interceptor.go
// ErrorCapturer specifies the implementation of a method to capture the given error
type ErrorCapturer interface {
CaptureError(err error, tags map[string]string) string
// SentryRavenInterceptor creates an interceptor which catches the errors from each service method and reports them to Sentry
func SentryRavenInterceptor(ec ErrorCapturer) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, _info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
resp, err := handler(ctx, req)
if err != nil {
You can’t perform that action at this time.