EDCD / EDMarketConnector

Downloads commodity market and other station data from the game Elite: Dangerous for use with all popular online and offline trading tools.
GNU General Public License v2.0
992 stars 155 forks source link

plugin hook to know when eddb or edsm are updated? #213

Closed inorton closed 5 years ago

inorton commented 7 years ago

The eddb and edsm modules can update their services at any time, it would be nice to have some form of notifications queue that these could publish to, then a plugin could subscribe to these notifications. The same could be useful for errors.

I'm really thinking that EDSMOverlay could print quick little "EDDB updated" messages occasionally using this.

How does this sound for an idea?

Marginal commented 7 years ago

The eddb module doesn't query eddb - mainly because there's no API to do so and themroc has no interest in providing one - so I don't see any way to tell whether the do has been updated recently.

The EDSM module does query EDSM to write log and obtain the system's "new" status for display. Is the latter of interest?

inorton commented 7 years ago

I'm more really just thinking a means of EDMC to announce it has done some thing, eg, having just uploaded the market data.

Marginal commented 7 years ago

So some kind of internal_event() callback, with various event types?

NoFoolLikeOne commented 7 years ago

I was just thinking about this. I guess not strictly the subject of the OP

I have a few plugins that I'm planning on writing the would need to get system data from EDSM. But if EDMC has already queried to find out if the system has been discovered then it would be better to pass the query results as an event to all plugins instead of having each plugin having to make the call themselves.

The event might look something like this..

{
    event:  "edsmQuery",
    result: "success\failure"
    name            : "Merope",
    coords          : {
        x               : -78.59375,
        y               : -149.625,
        z               : -340.53125
    },
    information     : {
        allegiance      : "Federation",
        government      : "Democracy",
        faction         : "Pleiades Resource Enterprise",
        factionState    : "Expansion",
        population      : 850000,
        reserve         : "Pristine",
        security        : "Medium",
        economy         : "Industrial"
    },
    primaryStar     : {
        type            : "B (Blue-White) Star",
        name            : "Merope",
        isScoopable     : true
    }
}

Then any installed plugin would be able to use the results without having to interface with EDSM at all.

inorton commented 7 years ago

Could you get the same data from eddb? Your app could be fed in real-time by the zeromq feed

NoFoolLikeOne commented 7 years ago

@inorton wrote:

Could you get the same data from eddb? Your app could be fed in real-time by the zeromq feed

I was making an assumption about how EDMC was finding out if the system was undiscovered. I thought it would be calling the systems API https://www.edsm.net/en/api-v1#endPointSystem which could provide all that information. But looking through the code I see it is using another mechanism.

I still think it would be a useful thing to do.

The plugin I am currently working on looks up the nearest Neutron star. Another I am planning will display population and alliegence info If a change request I put in to EDSM is accepted we could also a traffic report plugin

Each of those plugins would independently make a call to the same EDSM API

Marginal commented 5 years ago

EDSM and Inara callbacks documented at https://github.com/Marginal/EDMarketConnector/blob/master/PLUGINS.md#plugin-specific-events