Skip to content

Make API RESTful #44

Open
Open
@machinekoder

Description

The current Machinetalk API is probably not what one would call RESTful. A RESTful API consist of a small set of commands, resources, a defined serialization format and simple interfaces. Machinetalk is very close:

  • Protobuf works very well for consistent data serialization
  • We have something like resources -> I would call it services
  • We have relatively simple interfaces thanks to ZMQ

The only problem I see so far - we mapped the CNC stack API to the messaging layer. Basically mixing up protocol level types and RPC types. To create a RESTful API we should cleanly split up those two types of message identifiers to minimize the number of commands. See #40 and http://hintjens.com/blog:86

For example the types for the HAL remote component are in https://github.com/machinekit/machinetalk-protobuf/blob/master/src/machinetalk/protobuf/types.proto#L266 whereas the probably should be in sub-message of the protocol level Container message. The Container message should only contain types relevant on protocol level, meaning MT_PING, MT_ERROR, ...
The type for HALrcomp should be in a sub-message e.g. halrcomp defined by a protobuf extension (see #42), same for all other services.

The idea is that nobody needs to touch the protocol if not necessary. Extending machinetalk can then be done in a fork as well. Development of new services does not need to happen on the protocol level. The protocol level can be generic.

E.g. we have two basic types of "channels" at the moment:

  • PUB-SUB : to publish updates, need MT_PING, MT_FULL_UPDATE and MT_INCREMENTAL_UPDATE
  • REQ-REP or RPC: need MT_PING, MT_PING_ACKNOWLEDGE, MT_REQ, MT_ACK, MT_NACK and so on

Basically these base channels should have as few messages types as possible all implementation level protocol, such as halrcomp should be based on it. This will significantly decrease the effort to maintain the different protocols and to document the RESTful API. Encryptions and reliabilty can be added on base protocol level.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions