mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(gRPC) Bind gRPC services to an interface
By default gRPC it magically decides on an interface. The change will explicitly tell it what to use.
This commit is contained in:
parent
36a5c8b44c
commit
2ee492fb74
@ -3,6 +3,7 @@ package nu.marginalia.service.discovery.property;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
@ -12,6 +13,9 @@ public sealed interface ServiceEndpoint {
|
||||
int port();
|
||||
|
||||
URL toURL(String endpoint, String query);
|
||||
default InetSocketAddress toInetSocketAddress() {
|
||||
return new InetSocketAddress(host(), port());
|
||||
}
|
||||
|
||||
static ServiceEndpoint forSchema(ApiSchema schema, String host, int port) {
|
||||
return switch (schema) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package nu.marginalia.service.server;
|
||||
|
||||
import io.grpc.BindableService;
|
||||
import io.grpc.ServerBuilder;
|
||||
import io.grpc.*;
|
||||
import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder;
|
||||
import io.prometheus.client.Counter;
|
||||
import lombok.SneakyThrows;
|
||||
import nu.marginalia.mq.inbox.*;
|
||||
@ -108,7 +108,8 @@ public class Service {
|
||||
config.externalAddress()
|
||||
);
|
||||
|
||||
var grpcServerBuilder = ServerBuilder.forPort(grpcEndpoint.port());
|
||||
// Start the gRPC server
|
||||
var grpcServerBuilder = NettyServerBuilder.forAddress(grpcEndpoint.toInetSocketAddress());
|
||||
for (var grpcService : grpcServices) {
|
||||
grpcServerBuilder.addService(grpcService);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user