extending.md 1.98 KB
Newer Older
René Schöne's avatar
René Schöne committed
1
# Extending `RagConnect`
René Schöne's avatar
René Schöne committed
2

René Schöne's avatar
René Schöne committed
3
To add a new communication protocol, the following locations have to be changed (replace `ABC` and `abc` with the name of the protocol):
René Schöne's avatar
René Schöne committed
4

René Schöne's avatar
René Schöne committed
5
6
Within `ragconnect.base/src/main/resources`:
- Add a new handler `ABCHandler`, if appropriate, similar to the existing handlers
7
  - If further methods are needed for handler initialization, add a new template `abc.mustache` containing those procedures. Add `{{#usesABC}}{{> abc}}{{/usesABC}}` at the top of `ragconnect.mustache` to use this template
René Schöne's avatar
René Schöne committed
8
9
10
- In `receiveDefinition.mustache` and `sendDefinition.mustache`: add a new case in the switch statement defining the logic to happen for both definitions. If the new protocol is close to a PUSH semantic, follow `mqtt`. If it is closer to PULL semantic, follow `rest`.

Within `ragconnect.base/src/main/jastadd`:
11
12
- In `backend/Configuration`:
  - Add a new static boolean flag `usesABC` to indicate whether the protocol is used
René Schöne's avatar
René Schöne committed
13
- In `backend/Generation`:
14
  - Add new attributes for type `MRagConnect` for handler attribute and handler field, if needed
René Schöne's avatar
René Schöne committed
15
  - Add attributes for newly introduced references in changed mustache templates, if any
16
  - Add a newly constructed handler within the definition of `RagConnect.toMustache` with the needed fields (class name, construction snippet, handler attribute, handler field, the boolean flag you just added to Configuration)
René Schöne's avatar
René Schöne committed
17
18
19
20
21
22
23
24
- In `backend/MustacheNodesToYAML`:
  - Add key-value-pair for `usesABC` (and handler, if any)
  - Add key-value-pairs for newly introduced referemces in changed mustache templates, if any

In `ragconnect.base/src/main/java/org/jastadd/ragconnect/compiler/Compiler.java`:
- Add a new choice for `--protocols` similar to the existing ones
- Set the flag `usesABC` if the choice is given.
- Add code to add the handler to the list `handlers` if the choice is given, i.e., if `ASTNode.usesABC`
René Schöne's avatar
René Schöne committed
25
26

Furthermore, new test cases are appreciated. They can be added in the [ragconnect.rests repository](https://git-st.inf.tu-dresden.de/jastadd/ragconnect-tests)