Skip to content

Commit

Permalink
[core] Pass to FairMQ tasks abstract namespace endpoint paths
Browse files Browse the repository at this point in the history
O2-5457
OCTRL-946
  • Loading branch information
teo committed Oct 30, 2024
1 parent ddb067b commit 2cb8060
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions core/task/channel/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ import (
"github.com/rs/xid"
)

const ipcPathFormat = "/tmp/o2ipc-%s"
const IPC_PATH_FORMAT = "@o2ipc-%s"

type BindMap map[string]Endpoint


type Endpoint interface {
GetAddressFormat() AddressFormat
GetAddress() string
Expand Down Expand Up @@ -68,38 +67,37 @@ func EndpointEquals(e Endpoint, f Endpoint) bool {

func NewTcpEndpoint(host string, port uint64, transport TransportType) Endpoint {
return TcpEndpoint{
Host: host,
Port: port,
Host: host,
Port: port,
Transport: transport,
}
}

func NewBoundTcpEndpoint(port uint64, transport TransportType) Endpoint {
return TcpEndpoint{
Host: "*",
Port: port,
Host: "*",
Port: port,
Transport: transport,
}
}

func NewIpcEndpoint(path string, transport TransportType) Endpoint {
return IpcEndpoint{
Path: strings.TrimPrefix(path, "ipc://"),
Path: strings.TrimPrefix(path, "ipc://"),
Transport: transport,
}
}

func NewBoundIpcEndpoint(transport TransportType) Endpoint {
return IpcEndpoint{
Path: fmt.Sprintf(ipcPathFormat, xid.New().String()),
Path: fmt.Sprintf(IPC_PATH_FORMAT, xid.New().String()),
Transport: transport,
}
}


type TcpEndpoint struct {
Host string
Port uint64
Host string
Port uint64
Transport TransportType
}

Expand Down Expand Up @@ -134,9 +132,8 @@ func (t TcpEndpoint) ToBoundEndpoint() Endpoint {
}
}


type IpcEndpoint struct {
Path string
Path string
Transport TransportType
}

Expand All @@ -154,14 +151,14 @@ func (t IpcEndpoint) GetTransport() TransportType {

func (t IpcEndpoint) ToTargetEndpoint(_ string) Endpoint {
return IpcEndpoint{
Path: t.Path,
Path: t.Path,
Transport: t.Transport,
}
}

func (t IpcEndpoint) ToBoundEndpoint() Endpoint {
return IpcEndpoint{
Path: t.Path,
Path: t.Path,
Transport: t.Transport,
}
}

0 comments on commit 2cb8060

Please sign in to comment.