Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-14081 Networking module
  3. IGNITE-14715

Create an annotation processor for generating network message implementations

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.0-alpha3
    • networking

    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.

      Implementation details

      • Custom messages should be declared as interfaces extending NetworkMessage. Methods in these interfaces should correspond to the message fields, for example:
      @Message(type = ACTION_REQUEST)
      public interface ActionRequest extends NetworkMessage {
          String groupId();
          Command command();
      }
      
      • 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:
      @MessageTypes(moduleType = 10)
      class RaftMessageTypes {
          public final short ACTION_REQUEST = 1;
      }
      
      • Message implementations should have a generated Builder interface for creating new messages:
      public interface Builder {
          Builder command(Command cmd);
          Builder groupId(String groupId);
          ActionRequest build();
      }
      
      • Builder instances should be obtained using a generated factory, based on the current module type:
      public interface RaftClientMessageFactory {
          ActionRequestBuilder actionRequest();
          ActionResponseBuilder actionResponse();
      // ...
      }
      

      Attachments

        Issue Links

          Activity

            People

              apolovtcev Aleksandr Polovtsev
              apolovtcev Aleksandr Polovtsev
              Ivan Bessonov Ivan Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 5h 40m
                  5h 40m