Skip to content

Commit

Permalink
domain socket support foldin (#173)
Browse files Browse the repository at this point in the history
* domain socket support foldin

* Fix domain socket dep nightmare

* Hope springs eternal

* minor fluffing
  • Loading branch information
Hellblazer authored Dec 3, 2023
1 parent 7702f93 commit 0b41031
Show file tree
Hide file tree
Showing 25 changed files with 622 additions and 376 deletions.
14 changes: 9 additions & 5 deletions domain-epoll/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.salesforce.apollo</groupId>
<artifactId>apollo.app</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>domain-epoll</artifactId>
<name>Domain EPoll</name>
<name>Domain Sockets EPoll</name>
<description>Linux Unix Domain Socket Support</description>

<dependencies>
<dependency>
<groupId>com.salesforce.apollo</groupId>
<artifactId>domain-sockets</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>${netty.version}</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
*/
package com.salesforce.apollo.comm.grpc;

import java.io.IOException;
import java.util.concurrent.Executor;

import io.netty.channel.Channel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.EventLoopTaskQueueFactory;
Expand All @@ -21,57 +18,56 @@
import io.netty.util.concurrent.EventExecutorChooserFactory;
import io.netty.util.concurrent.RejectedExecutionHandler;

import java.io.IOException;
import java.util.concurrent.Executor;

/**
* @author hal.hildebrand
*
*/
public class DomainSockets {
public class DomainSocketsLinux implements DomainSockets {

public static Class<? extends Channel> getChannelType() {
public Class<? extends Channel> getChannelType() {
return EpollDomainSocketChannel.class;
}

public static EventLoopGroup getEventLoopGroup() {
public EventLoopGroup getEventLoopGroup() {
return new EpollEventLoopGroup();
}

public static EventLoopGroup getEventLoopGroup(int threads) {
public EventLoopGroup getEventLoopGroup(int threads) {
return new EpollEventLoopGroup(threads);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor) {
public EventLoopGroup getEventLoopGroup(int threads, Executor executor) {
return new EpollEventLoopGroup(threads, executor);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory) {
public EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory) {
return new EpollEventLoopGroup(threads, executor, chooserFactory, selectStrategyFactory);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler) {
public EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler) {
return new EpollEventLoopGroup(threads, executor, chooserFactory, selectStrategyFactory,
rejectedExecutionHandler);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler,
EventLoopTaskQueueFactory queueFactory) {
public EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler,
EventLoopTaskQueueFactory queueFactory) {
return new EpollEventLoopGroup(threads, executor, chooserFactory, selectStrategyFactory,
rejectedExecutionHandler, queueFactory);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
SelectStrategyFactory selectStrategyFactory) {
public EventLoopGroup getEventLoopGroup(int threads, Executor executor,
SelectStrategyFactory selectStrategyFactory) {
return new EpollEventLoopGroup(threads, executor, selectStrategyFactory);
}

public static PeerCredentials getPeerCredentials(Channel channel) {
public PeerCredentials getPeerCredentials(Channel channel) {
if (channel instanceof EpollDomainSocketChannel ep) {
try {
return ep.peerCredentials();
Expand All @@ -83,7 +79,7 @@ public static PeerCredentials getPeerCredentials(Channel channel) {
}
}

public static Class<? extends ServerDomainSocketChannel> getServerDomainSocketChannelClass() {
public Class<? extends ServerDomainSocketChannel> getServerDomainSocketChannelClass() {
return EpollServerDomainSocketChannel.class;
}
}
12 changes: 8 additions & 4 deletions domain-kqueue/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.salesforce.apollo</groupId>
<artifactId>apollo.app</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<name>Domain KQueue</name>
<name>Domain Sockets KQueue</name>
<description>Mac/OSx Unix Domain Socket Support</description>
<artifactId>domain-kqueue</artifactId>

<dependencies>
<dependency>
<groupId>com.salesforce.apollo</groupId>
<artifactId>domain-sockets</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>${netty.version}</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
*/
package com.salesforce.apollo.comm.grpc;

import java.io.IOException;
import java.util.concurrent.Executor;

import io.netty.channel.Channel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.EventLoopTaskQueueFactory;
Expand All @@ -21,65 +18,73 @@
import io.netty.util.concurrent.EventExecutorChooserFactory;
import io.netty.util.concurrent.RejectedExecutionHandler;

import java.io.IOException;
import java.util.concurrent.Executor;

/**
* @author hal.hildebrand
*
*/
public class DomainSockets {
public class DomainSocketsOSX implements DomainSockets {
static {
try {
final var sock = new KQueueServerDomainSocketChannel();
sock.close();
} catch (Throwable t) {
// t.printStackTrace();
// t.printStackTrace();
}
}

public static Class<? extends Channel> getChannelType() {
@Override
public Class<? extends Channel> getChannelType() {
return KQueueDomainSocketChannel.class;
}

public static EventLoopGroup getEventLoopGroup() {
@Override
public EventLoopGroup getEventLoopGroup() {
return new KQueueEventLoopGroup();
}

public static EventLoopGroup getEventLoopGroup(int threads) {
@Override
public EventLoopGroup getEventLoopGroup(int threads) {
return new KQueueEventLoopGroup(threads);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor) {
@Override
public EventLoopGroup getEventLoopGroup(int threads, Executor executor) {
return new KQueueEventLoopGroup(threads, executor);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory) {
@Override
public EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory) {
return new KQueueEventLoopGroup(threads, executor, chooserFactory, selectStrategyFactory);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler) {
@Override
public EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler) {
return new KQueueEventLoopGroup(threads, executor, chooserFactory, selectStrategyFactory,
rejectedExecutionHandler);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler,
EventLoopTaskQueueFactory queueFactory) {
@Override
public EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler,
EventLoopTaskQueueFactory queueFactory) {
return new KQueueEventLoopGroup(threads, executor, chooserFactory, selectStrategyFactory,
rejectedExecutionHandler, queueFactory);
}

public static EventLoopGroup getEventLoopGroup(int threads, Executor executor,
SelectStrategyFactory selectStrategyFactory) {
@Override
public EventLoopGroup getEventLoopGroup(int threads, Executor executor,
SelectStrategyFactory selectStrategyFactory) {
return new KQueueEventLoopGroup(threads, executor, selectStrategyFactory);
}

public static PeerCredentials getPeerCredentials(Channel channel) {
@Override
public PeerCredentials getPeerCredentials(Channel channel) {
if (channel instanceof KQueueDomainSocketChannel ep) {
try {
return ep.peerCredentials();
Expand All @@ -91,7 +96,8 @@ public static PeerCredentials getPeerCredentials(Channel channel) {
}
}

public static Class<? extends ServerDomainSocketChannel> getServerDomainSocketChannelClass() {
@Override
public Class<? extends ServerDomainSocketChannel> getServerDomainSocketChannelClass() {
return KQueueServerDomainSocketChannel.class;
}
}
21 changes: 21 additions & 0 deletions domain-sockets/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.salesforce.apollo</groupId>
<artifactId>apollo.app</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>domain-sockets</artifactId>
<name>Domain Sockets</name>
<description>Domain Socket Access Interface</description>

<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.salesforce.apollo.comm.grpc;

import io.netty.channel.Channel;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.EventLoopTaskQueueFactory;
import io.netty.channel.SelectStrategyFactory;
import io.netty.channel.unix.PeerCredentials;
import io.netty.channel.unix.ServerDomainSocketChannel;
import io.netty.util.concurrent.EventExecutorChooserFactory;
import io.netty.util.concurrent.RejectedExecutionHandler;

import java.util.concurrent.Executor;

public interface DomainSockets {
Class<? extends Channel> getChannelType();

EventLoopGroup getEventLoopGroup();

EventLoopGroup getEventLoopGroup(int threads);

EventLoopGroup getEventLoopGroup(int threads, Executor executor);

EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory);

EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler);

EventLoopGroup getEventLoopGroup(int threads, Executor executor, EventExecutorChooserFactory chooserFactory,
SelectStrategyFactory selectStrategyFactory,
RejectedExecutionHandler rejectedExecutionHandler,
EventLoopTaskQueueFactory queueFactory);

EventLoopGroup getEventLoopGroup(int threads, Executor executor, SelectStrategyFactory selectStrategyFactory);

PeerCredentials getPeerCredentials(Channel channel);

Class<? extends ServerDomainSocketChannel> getServerDomainSocketChannelClass();
}
Loading

0 comments on commit 0b41031

Please sign in to comment.