blob: dbff83cad900ac22c774cfdce5497ce7903a02eb (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.messagebus;
import com.yahoo.component.Version;
import com.yahoo.messagebus.routing.RoutingPolicy;
/**
* Interface implemented by the concrete application message protocol.
*
* @author bratseth
* @author Simon Thoresen Hult
*/
public interface Protocol {
/** Returns a global unique name for this protocol. */
String getName();
/**
* Encodes the protocol specific data of a routable into a byte array.
*
* @param version the version to encode for
* @param routable the routable to encode
* @return the encoded data
*/
byte[] encode(Version version, Routable routable);
/**
* Decodes the protocol specific data into a routable of the correct type.
*
* @param version the version of the serialized routable
* @param payload the payload to decode from
* @return the decoded routable, or null if it could not be decoded
*/
Routable decode(Version version, byte[] payload);
/**
* Create a policy of the named type with the named param passed to the constructor of that policy.
*
* @param name the name of the policy to create
* @param param the parameter to that policy's constructor
* @return the created policy
*/
RoutingPolicy createPolicy(String name, String param);
}
|