implement local replication using new local transport
The new local transport uses socketpair() and a switchboard based on client identities. The special local job type is gone, which is good since it does not fit into the 'Active/Passive side ' + 'mode' concept used to implement the duality of push/sink | pull/source.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package connecter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zrepl/zrepl/config"
|
||||
"github.com/zrepl/zrepl/daemon/serve"
|
||||
"net"
|
||||
)
|
||||
|
||||
type LocalConnecter struct {
|
||||
clientIdentity string
|
||||
}
|
||||
|
||||
func LocalConnecterFromConfig(in *config.LocalConnect) (*LocalConnecter, error) {
|
||||
if in.ClientIdentity == "" {
|
||||
return nil, fmt.Errorf("ClientIdentity must not be empty")
|
||||
}
|
||||
return &LocalConnecter{in.ClientIdentity}, nil
|
||||
}
|
||||
|
||||
func (c *LocalConnecter) Connect(dialCtx context.Context) (conn net.Conn, err error) {
|
||||
switchboard := serve.GetLocalListenerSwitchboard()
|
||||
return switchboard.DialContext(dialCtx, c.clientIdentity)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user