Structure serialization #225
LeadcodeDev
started this conversation in
Proposal
Replies: 1 comment
-
Your proposal is really clean, and I think it's cool to include a method for retrieving channels via .fetch() or .getServer() on the member to retrieve its server. The advantage is that it in no way prevents you from being able to inject new behaviours via your IoC, for example if the business logic changes or you even want to optimise certain flows (e.g. fetch in cache if the data exists). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
During the two years of development on this new version of Mineral's core, we've experimented with several approaches to managing our data from Discord's Websocket and API.
Introduction
Today, we deliver all data accessible from a top-level data structure.
This involves retrieving additional resources when the initial structure is supposed to be able to access them; either via the cache if it has data, or via a request to the Discord API.
One example is more telling :
Problems
The problem with the way things currently work is that the Discord API does not systematically provide us with all the resources we need to model all the class depths; we have to make additional requests in the background, which are therefore imposed on you by the framework.
So even if the final developer doesn't need certain data, it's still there.
The problem as it stands is that we have to retrieve a multitude of resources for a single ‘small’ data structure.
This implies and imposes this obligation on the end developer.
Proposal
We want to experiment with a more ‘atomic’ approach aimed at reducing complexity and our dependence on multiple resources as much as possible. To this end, we propose a slightly different approach based on the ‘resource on demand’ principle.
An example is (once again) more telling :
The fact of
forcing
the end developer to request a resource explicitly implies more code to write but drastically reduces the executive delay of the relative code because the data structure to be shared with the "view" (consumer of events...) is radically minimised.This simplifies and further reduces dependency on a cache (redis, memory, etc.) and is therefore in line with our philosophy.
With this in mind, the
fetch
method will query the cache first and then Discord's HTTP API to retrieve the missing data.Examples
In the context of a server resource, a request to the Discord API provides us with neither
members
norchannels
.So each point that is not "pre-loaded" could be the subject of a
manager
which would act as a node.In this example,
channels
would be a node allowing recovery actions to be performed according to the needs of the end developer (fetch
,resolve
...).Hypothetically we can apply this principle to users :
What do you think ?
Do you have any ideas for improvements or alternatives ?
Beta Was this translation helpful? Give feedback.
All reactions