aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/main/java/com/yahoo/messagebus/network/rpc/RPCService.java
blob: 825d50badd213984ac7177b19d256202b688f252 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.messagebus.network.rpc;

import com.yahoo.jrt.slobrok.api.IMirror;

/**
 * An RPCService represents a set of remote sessions matching a service pattern. The sessions are monitored using the
 * slobrok. If multiple sessions are available, round robin is used to balance load between them.
 *
 * @author havardpe
 */
public interface RPCService {

    static RPCService create(IMirror mirror, String pattern) {
        if (pattern.startsWith("tcp/")) {
            return new TcpRPCService(pattern);
        }
        return new NamedRPCService(mirror, pattern);
    }

    /**
     * Resolve a concrete address from this service. This service may represent multiple remote sessions, so this will
     * select one that is online.
     *
     * @return A concrete service address.
     */
    RPCServiceAddress resolve();

}