nonstorio / nosenstory

NosenStory API, client-agnostic interface for maintaining NosenStory game process across multiple chat applications.
https://nosenstory.github.io
Apache License 2.0
0 stars 0 forks source link

Unified NS API; transfer bot-related logic to another repository #9

Open vintprox opened 4 years ago

vintprox commented 4 years ago

As the part of work related to nonstory/nonstory-design#9 and #6, I plan to separate NS API from Discord bot, effectively making it more client-agnostic. NS API must be solely NonStory-specific and maintain database on its own rather than allowing direct access to database from bot and taking responsibility brought with Discord identities, because they are only a small part of the game and must be interpreted by bot itself.

NS API must wrap all methods and abstractions (as using NsRoom for representing Discord channels and NsServer for guilds) affecting the game (which includes management part). In the end, NS API is a separate protocol server as dependency for bots, each running per one type of chat server, like for Discord, IRC, Slack, etc.

It leads us to the conclusion that client-targeted bots must remain strictly in separate repositories and not considered as part affecting pure NS API. Client must provide appropriate app token to operate on it.

vintprox commented 4 years ago

Despite of the reason to make it client-agnostic, I'd like to clarify that vendor-specific artifacts will affect the models in Bot API.

For example, NsServer doesn't rely only on integer ID, when it comes to servers other than Discord - instead there could be connection string as prime identifier. There must be a way to determine technical differences between servers and apply them to models appropriately.

Update: look at notes in #3. I'll favor unified abstractions upon vendors.

vintprox commented 4 years ago

Considering that bot acts as intermediary between player and NS API, good choice for performant connection between bot and NS API would be gRPC, which also is less consuming compared to REST.

vintprox commented 4 years ago

3 contains notes about what are NSApp (formerly NSPlatform) and other models.

vintprox commented 4 years ago

Making basic gRPC service in #11. Having API on machine separated from bots is a necessity because load for bots is huge and they must not stop each other, also because of sharding opportunities it fosters bot can balance loading without directly sharing the state between instances. State of the game is NS API's responsibility.