You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Aleksandr Polovtcev (Jira)" <ji...@apache.org> on 2021/05/13 14:36:00 UTC

[jira] [Updated] (IGNITE-14715) Create an annotation processor for generating network message implementations

     [ https://issues.apache.org/jira/browse/IGNITE-14715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aleksandr Polovtcev updated IGNITE-14715:
-----------------------------------------
    Description: 
Currently all {{NetworkMessage}} implementations are created by hand which is inconvenient (e.g. one needs to declare constructors and getters). It is proposed to automatically generate these implementations using an annotation processor.

h3. Implementation details

 * Custom messages should be declared as interfaces extending {{NetworkMessage}}. Methods in these interfaces should correspond to the message fields, for example:

{code:java}
@Message(type = ACTION_REQUEST)
public interface ActionRequest extends NetworkMessage {
    String groupId();
    Command command();
}
{code}

* Every message interface should be annotated with the {{@Message}} interface, with a *message type* parameter of type {{short}}, unique across a *module*. All message types should be manually listed in an interface marked with the {{@MessageTypes}} annotation with a *module identifier*. For example:

{code:java}
@MessageTypes(moduleType = 10)
class RaftMessageTypes {
    public final short ACTION_REQUEST = 1;
}
{code}

 * Message implementations should have a generated {{Builder}} interface for creating new messages:

{code:java}
public interface Builder {
    Builder command(Command cmd);
    Builder groupId(String groupId);
    ActionRequest build();
}
{code}

* {{Builder}} instances should be obtained using a generated factory, based on the current module type:

{code:java}
public interface RaftClientMessageFactory {
    ActionRequestBuilder actionRequest();
    ActionResponseBuilder actionResponse();
// ...
}
{code}




> Create an annotation processor for generating network message implementations
> -----------------------------------------------------------------------------
>
>                 Key: IGNITE-14715
>                 URL: https://issues.apache.org/jira/browse/IGNITE-14715
>             Project: Ignite
>          Issue Type: Sub-task
>          Components: networking
>            Reporter: Aleksandr Polovtcev
>            Priority: Minor
>
> Currently all {{NetworkMessage}} implementations are created by hand which is inconvenient (e.g. one needs to declare constructors and getters). It is proposed to automatically generate these implementations using an annotation processor.
> h3. Implementation details
>  * Custom messages should be declared as interfaces extending {{NetworkMessage}}. Methods in these interfaces should correspond to the message fields, for example:
> {code:java}
> @Message(type = ACTION_REQUEST)
> public interface ActionRequest extends NetworkMessage {
>     String groupId();
>     Command command();
> }
> {code}
> * Every message interface should be annotated with the {{@Message}} interface, with a *message type* parameter of type {{short}}, unique across a *module*. All message types should be manually listed in an interface marked with the {{@MessageTypes}} annotation with a *module identifier*. For example:
> {code:java}
> @MessageTypes(moduleType = 10)
> class RaftMessageTypes {
>     public final short ACTION_REQUEST = 1;
> }
> {code}
>  * Message implementations should have a generated {{Builder}} interface for creating new messages:
> {code:java}
> public interface Builder {
>     Builder command(Command cmd);
>     Builder groupId(String groupId);
>     ActionRequest build();
> }
> {code}
> * {{Builder}} instances should be obtained using a generated factory, based on the current module type:
> {code:java}
> public interface RaftClientMessageFactory {
>     ActionRequestBuilder actionRequest();
>     ActionResponseBuilder actionResponse();
> // ...
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)