github.com/anycable/anycable-go@v1.5.1/rpc/inprocess.go (about)

     1  package rpc
     2  
     3  import (
     4  	"log/slog"
     5  
     6  	"github.com/fullstorydev/grpchan"
     7  	"github.com/fullstorydev/grpchan/inprocgrpc"
     8  
     9  	pb "github.com/anycable/anycable-go/protos"
    10  )
    11  
    12  func NewInprocessServiceDialer(service pb.RPCServer, stateHandler ClientHelper) Dialer {
    13  	handlers := grpchan.HandlerMap{}
    14  	inproc := &inprocgrpc.Channel{}
    15  
    16  	pb.RegisterHandlerRPC(handlers, service)
    17  	handlers.ForEach(inproc.RegisterService)
    18  
    19  	return func(c *Config, l *slog.Logger) (pb.RPCClient, ClientHelper, error) {
    20  		inprocClient := pb.NewRPCChannelClient(inproc)
    21  		return inprocClient, stateHandler, nil
    22  	}
    23  }