You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by LeadcodeDev December 25, 2024
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 :
// Top-level structurefinal member =Member();
// Second-level structure accessible by chaining from the memberfinal server = member.server;
// Third level structurefinal channels = member.server.channels;
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 :
// Top-level structurefinal member =Member();
// New first-level structurefinal server =await member.getServer();
// (Again) a new top-level structurefinal channels =await server.channels.fetch();
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 nor channels.
So each point that is not "pre-loaded" could be the subject of a manager which would act as a node.
Discussed in #225
Originally posted by LeadcodeDev December 25, 2024
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 ?
The text was updated successfully, but these errors were encountered: