Giter Site home page Giter Site logo

API Design about devzat HOT 6 CLOSED

quackduck avatar quackduck commented on May 14, 2024
API Design

from devzat.

Comments (6)

CodeLongAndProsper90 avatar CodeLongAndProsper90 commented on May 14, 2024 1

I think that having plugins be spawned as children and passing messages across the child's stdin/stdout is the simplest way to do it. Example session:

< { 'action': 'register_cmd', 'name': 'hello', 'usage': 'hello <world>', 'args': [] }
> { 'event: 'command', 'invoker': { 'name': 'John Doe', 'id': '314159' }, 'args': [] }
# processes event
< { 'action': 'send_msg', 'to': '314159', 'text': 'Hello, World!' }

actions:

  • register_cmd
  • register_listener
  • send_msg
  • set_nick
  • set_color
  • set_pronouns
  • get_nick
  • get_color
  • get_pronouns

events:

  • msg
  • join
  • kick

from devzat.

Merlin04 avatar Merlin04 commented on May 14, 2024 1

For reference here's the API design idea I came up with on the slack. It's missing some important things but it covers most of the core features (like events and middleware):

Actions

 register_cmd(name: string)
 send_message(from?: string, ephemeral?: bool)
 send_image(src_type: "file" | "url" | "b64", src: string)
 register_listener(event: "send" | "something else?", middleware?: bool, once?: bool)
 mw_edit_message(text?: string)
 mw_done()

Messages

 event(name: string, data?: object)
 cmd(name: string, args: string)

The actual data format would look something like

 {
     type: string,
     args: object
 }

You could also batch actions in a single communication by putting them in an array

If middleware is enabled for an event listener the server will not proceed with sending the message until mw_done is called, and once just makes the listener only fire for the next event (useful for bots)

from devzat.

Merlin04 avatar Merlin04 commented on May 14, 2024 1

@quackduck I've heard gRPC is good for efficient inter-process communication but I have no idea how practical it is/how easy it is to integrate with plugins

from devzat.

quackduck avatar quackduck commented on May 14, 2024

IIRC you wanted this to use gRPC, right?

from devzat.

Merlin04 avatar Merlin04 commented on May 14, 2024

It also might be a good idea to consider versioning the API, so plugins can detect breaking changes

from devzat.

quackduck avatar quackduck commented on May 14, 2024

๐ŸŽ‰ current solution: 3025512

(Thanks Benjamin!)

from devzat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.