Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion provisionersdk/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Serve(ctx context.Context, server proto.DRPCProvisionerServer, options *Ser
if options.Listener == nil {
config := yamux.DefaultConfig()
config.LogOutput = io.Discard
stdio, err := yamux.Server(readWriteCloser{
stdio, err := yamux.Server(&readWriteCloser{
ReadCloser: os.Stdin,
Writer: os.Stdout,
}, config)
Expand All @@ -54,6 +54,9 @@ func Serve(ctx context.Context, server proto.DRPCProvisionerServer, options *Ser
// short-lived processes that can be executed concurrently.
err = srv.Serve(ctx, options.Listener)
if err != nil {
if errors.Is(err, io.EOF) {
return nil
}
if errors.Is(err, context.Canceled) {
return nil
}
Expand All @@ -67,3 +70,8 @@ func Serve(ctx context.Context, server proto.DRPCProvisionerServer, options *Ser
}
return nil
}

type readWriteCloser struct {
io.ReadCloser
io.Writer
}
20 changes: 4 additions & 16 deletions provisionersdk/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provisionersdk
import (
"context"
"io"
"net"

"github.com/hashicorp/yamux"
"storj.io/drpc"
Expand All @@ -17,22 +18,14 @@ const (

// TransportPipe creates an in-memory pipe for dRPC transport.
func TransportPipe() (*yamux.Session, *yamux.Session) {
clientReader, clientWriter := io.Pipe()
serverReader, serverWriter := io.Pipe()
c1, c2 := net.Pipe()
yamuxConfig := yamux.DefaultConfig()
yamuxConfig.LogOutput = io.Discard
client, err := yamux.Client(&readWriteCloser{
ReadCloser: clientReader,
Writer: serverWriter,
}, yamuxConfig)
client, err := yamux.Client(c1, yamuxConfig)
if err != nil {
panic(err)
}

server, err := yamux.Server(&readWriteCloser{
ReadCloser: serverReader,
Writer: clientWriter,
}, yamuxConfig)
server, err := yamux.Server(c2, yamuxConfig)
if err != nil {
panic(err)
}
Expand All @@ -44,11 +37,6 @@ func Conn(session *yamux.Session) drpc.Conn {
return &multiplexedDRPC{session}
}

type readWriteCloser struct {
io.ReadCloser
io.Writer
}

// Allows concurrent requests on a single dRPC connection.
// Required for calling functions concurrently.
type multiplexedDRPC struct {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy