Phase 888: registry pull opts auto-resolve + host/search pull mixin extract (v0.8.855)
Non-breaking refactor — buildGuildGossipRpcPullOptsFromRegistry() resolves rpcMethod from the gossip RPC registry for all pull paths; fetchMessageSearchGuildGossipRpcPullByConfig for search mesh; platform-host-rpc-pull-mixin shared by mesh RPC mixin. Mesh sync/member page and search mixins drop manual RPC id wiring. test:ci-phase888 passes (46/50, cutover deferred).
This commit is contained in:
@@ -92,6 +92,8 @@ Application facade: one `PearcordPlatform` class that wires identity, database,
|
||||
|
||||
**Phase 822 (v0.8.789):** Triple-peer topology via `guild-mesh-topology` + `getMeshStabilityStats`. Bundle: `npm run test:ci-phase822`.
|
||||
|
||||
**Phase 888 (v0.8.855):** Registry pull opts auto-resolve (`buildGuildGossipRpcPullOptsFromRegistry`) + host/search pull mixin extract + message search config pull. Bundle: `npm run test:ci-phase888`.
|
||||
|
||||
**Phase 887 (v0.8.854):** Registry RPC method resolve + targeted export pull mixin + handler manifest validation. Bundle: `npm run test:ci-phase887`.
|
||||
|
||||
**Phase 886 (v0.8.853):** Registry-driven handler map + `bindGuildGossipRpcHandlers()` + wire bind mixin extract. Bundle: `npm run test:ci-phase886`.
|
||||
|
||||
@@ -10,9 +10,15 @@ const {
|
||||
requestGuildGossipRpcFromPeers
|
||||
} = require('./gossip-rpc-session')
|
||||
const { pickFirstGuildRpcResponse } = require('./gossip-rpc-validators')
|
||||
const { buildGuildGossipRpcPullOpts } = require('./gossip-rpc-pull-config')
|
||||
const { buildTargetedGuildGossipRpcFetchPayload } = require('./gossip-rpc-payload')
|
||||
const { lookupGuildGossipRpcPullRegistryEntryByConfig, resolveGuildGossipRpcMethodId } = require('./gossip-rpc-registry')
|
||||
const {
|
||||
buildTargetedGuildGossipRpcFetchPayload,
|
||||
buildMessageSearchGuildGossipRpcFetchPayload
|
||||
} = require('./gossip-rpc-payload')
|
||||
const {
|
||||
lookupGuildGossipRpcPullRegistryEntryByConfig,
|
||||
resolveGuildGossipRpcMethodId
|
||||
} = require('./gossip-rpc-registry')
|
||||
const { buildGuildGossipRpcPullOptsFromRegistry } = require('./gossip-rpc-registry-pull')
|
||||
|
||||
/** Shared peer resolve + wire prep for guild gossip RPC fanout (Phase 880). */
|
||||
async function prepareGuildGossipRpcFanoutRequest (platform, opts = {}) {
|
||||
@@ -129,7 +135,7 @@ async function fetchTargetedGuildGossipRpcPullHit (
|
||||
const requestIdFn = typeof nextRequestId === 'function' ? nextRequestId : () => nextRequestId
|
||||
return fetchGuildGossipRpcPullHit(
|
||||
platform,
|
||||
buildGuildGossipRpcPullOpts(configKey, {
|
||||
buildGuildGossipRpcPullOptsFromRegistry(configKey, {
|
||||
targetMemberId: opts.targetMemberId || null,
|
||||
rpcMethod,
|
||||
buildPayload: async ({ guildId }) =>
|
||||
@@ -148,13 +154,34 @@ async function fetchTargetedGuildGossipRpcPullHit (
|
||||
async function fetchGuildGossipRpcPullByConfig (platform, configKey, overrides = {}) {
|
||||
const entry = lookupGuildGossipRpcPullRegistryEntryByConfig(configKey)
|
||||
if (!entry) return null
|
||||
const opts = buildGuildGossipRpcPullOpts(configKey, overrides)
|
||||
const opts = buildGuildGossipRpcPullOptsFromRegistry(configKey, overrides)
|
||||
if (!opts) return null
|
||||
if (entry.pullKind === 'hostHit') return fetchGuildGossipRpcFromHostHit(platform, opts)
|
||||
if (entry.pullKind === 'pullMerged') return fetchGuildGossipRpcPullMerged(platform, opts)
|
||||
return fetchGuildGossipRpcPullHit(platform, opts)
|
||||
}
|
||||
|
||||
/** Message search merge pull via registry config + payload builder (Phase 888). */
|
||||
async function fetchMessageSearchGuildGossipRpcPullByConfig (
|
||||
platform,
|
||||
guildId,
|
||||
query,
|
||||
opts = {},
|
||||
requestId
|
||||
) {
|
||||
if (!platform.guild?.guild || platform.guild.guild.id !== guildId) return null
|
||||
return fetchGuildGossipRpcPullByConfig(platform, 'messageSearchMerge', {
|
||||
buildPayload: async ({ guildId: gid }) =>
|
||||
buildMessageSearchGuildGossipRpcFetchPayload({
|
||||
guildId: gid,
|
||||
requestId,
|
||||
query,
|
||||
opts,
|
||||
requestedBy: platform.identity?.user?.id || null
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/** Targeted pullHit via registry config + RPC method resolve (Phase 887). */
|
||||
async function fetchTargetedGuildGossipRpcPullByConfig (
|
||||
platform,
|
||||
@@ -182,5 +209,6 @@ module.exports = {
|
||||
fetchGuildGossipRpcPullMerged,
|
||||
fetchTargetedGuildGossipRpcPullHit,
|
||||
fetchTargetedGuildGossipRpcPullByConfig,
|
||||
fetchGuildGossipRpcPullByConfig
|
||||
fetchGuildGossipRpcPullByConfig,
|
||||
fetchMessageSearchGuildGossipRpcPullByConfig
|
||||
}
|
||||
|
||||
+3
-1
@@ -11,6 +11,7 @@ const payload = require('./gossip-rpc-payload')
|
||||
const registry = require('./gossip-rpc-registry')
|
||||
const responders = require('./gossip-rpc-responders')
|
||||
const handlerBind = require('./gossip-rpc-handler-bind')
|
||||
const registryPull = require('./gossip-rpc-registry-pull')
|
||||
|
||||
module.exports = {
|
||||
...peer,
|
||||
@@ -22,5 +23,6 @@ module.exports = {
|
||||
...payload,
|
||||
...registry,
|
||||
...responders,
|
||||
...handlerBind
|
||||
...handlerBind,
|
||||
...registryPull
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
const { buildGuildGossipRpcPullOpts } = require('./gossip-rpc-pull-config')
|
||||
const {
|
||||
lookupGuildGossipRpcPullRegistryEntryByConfig,
|
||||
resolveGuildGossipRpcMethodId
|
||||
} = require('./gossip-rpc-registry')
|
||||
|
||||
/** Merge pull config with registry-resolved rpcMethod when omitted (Phase 888). */
|
||||
function buildGuildGossipRpcPullOptsFromRegistry (configKey, overrides = {}) {
|
||||
const entry = lookupGuildGossipRpcPullRegistryEntryByConfig(configKey)
|
||||
if (!entry) return null
|
||||
const rpcMethod =
|
||||
overrides.rpcMethod != null
|
||||
? overrides.rpcMethod
|
||||
: resolveGuildGossipRpcMethodId(entry.methodKey)
|
||||
if (rpcMethod == null) return null
|
||||
return buildGuildGossipRpcPullOpts(configKey, { ...overrides, rpcMethod })
|
||||
}
|
||||
|
||||
module.exports = { buildGuildGossipRpcPullOptsFromRegistry }
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const { fetchGuildGossipRpcPullByConfig } = require('../../../gossip-rpc-pull')
|
||||
|
||||
/** Host-prefer registry config RPC pull helper (Phase 888). */
|
||||
const platformHostRpcPullMixin = {
|
||||
async _fetchHostGuildGossipRpcPullByConfig (configKey, overrides = {}) {
|
||||
return fetchGuildGossipRpcPullByConfig(this, configKey, overrides)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { platformHostRpcPullMixin }
|
||||
@@ -1,23 +1,23 @@
|
||||
'use strict'
|
||||
|
||||
const sharedScope = require('../../../platform-pearcord-shared-imports')
|
||||
const {
|
||||
fetchGuildGossipRpcPullByConfig,
|
||||
resolveGuildGossipRpcHostPeerId,
|
||||
markRpcResponse,
|
||||
buildGuildSyncHostRpcFetchPayload,
|
||||
buildMemberPageHostRpcFetchPayload
|
||||
} = require('../../../gossip-rpc-pull')
|
||||
const { platformHostRpcPullMixin } = require('./platform-host-rpc-pull-mixin')
|
||||
|
||||
/** Guild sync + member page protomux-rpc pull helpers (Phase 882 extract). */
|
||||
const platformMeshRpcPullMixin = {
|
||||
...platformHostRpcPullMixin,
|
||||
|
||||
async _tryMemberPageRequestRpc (offset = 0) {
|
||||
const guildId = this.guild?.guild?.id
|
||||
const userId = this.identity?.user?.id
|
||||
if (!guildId || !userId) return null
|
||||
const off = Math.max(0, Number(offset) || 0)
|
||||
const page = await fetchGuildGossipRpcPullByConfig(this, 'memberPageHost', {
|
||||
rpcMethod: sharedScope.RPC.MEMBER_PAGE_REQUEST,
|
||||
const page = await this._fetchHostGuildGossipRpcPullByConfig('memberPageHost', {
|
||||
buildPayload: async ({ guildId: gid }) =>
|
||||
buildMemberPageHostRpcFetchPayload({
|
||||
guildId: gid,
|
||||
@@ -42,9 +42,8 @@ const platformMeshRpcPullMixin = {
|
||||
const wm = this._getGuildSyncWatermark(guildId)
|
||||
const ch = channelId || this.activeChannelId || null
|
||||
const hostPublicKey = await this._lookupGuildHostPublicKey(this.guild.guild)
|
||||
const bundle = await fetchGuildGossipRpcPullByConfig(this, 'guildSyncHost', {
|
||||
const bundle = await this._fetchHostGuildGossipRpcPullByConfig('guildSyncHost', {
|
||||
hostPublicKey,
|
||||
rpcMethod: sharedScope.RPC.GUILD_SYNC_REQUEST,
|
||||
beforeRequest: async (platform) =>
|
||||
platform.guild.guild.ownerId === platform.identity?.user?.id,
|
||||
buildPayload: async ({ guildId: gid }) =>
|
||||
@@ -99,6 +98,7 @@ const platformMeshRpcPullMixin = {
|
||||
},
|
||||
|
||||
_fanoutGuildSyncRequestWithAckWatermarks (channelId) {
|
||||
const sharedScope = require('../../../platform-pearcord-shared-imports')
|
||||
if (sharedScope.isRpcGossipRequestEnabled?.()) {
|
||||
void this._tryGuildSyncRequestRpc(channelId)
|
||||
.then((rpc) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ const searchScope = require('pearcord-search')
|
||||
const sharedScope = require('../../../platform-pearcord-shared-imports')
|
||||
const { id } = require('../../../platform-class-imports')
|
||||
const {
|
||||
fetchGuildGossipRpcPullByConfig,
|
||||
fetchMessageSearchGuildGossipRpcPullByConfig,
|
||||
buildMessageSearchGuildGossipRpcFetchPayload
|
||||
} = require('../../../gossip-rpc-pull')
|
||||
const { platformSearchRpcRespondersMixin } = require('./platform-search-rpc-responders-mixin')
|
||||
@@ -15,17 +15,13 @@ const platformSearchMeshGossipMixin = {
|
||||
async _fetchGuildSearchFromMeshRpc (guildId, query, opts = {}) {
|
||||
if (!this.guild?.guild || this.guild.guild.id !== guildId) return null
|
||||
const requestId = id()
|
||||
return fetchGuildGossipRpcPullByConfig(this, 'messageSearchMerge', {
|
||||
rpcMethod: sharedScope.RPC.MESSAGE_SEARCH_REQUEST,
|
||||
buildPayload: async ({ guildId: gid }) =>
|
||||
buildMessageSearchGuildGossipRpcFetchPayload({
|
||||
guildId: gid,
|
||||
requestId,
|
||||
query,
|
||||
opts,
|
||||
requestedBy: this.identity.user?.id || null
|
||||
})
|
||||
})
|
||||
return fetchMessageSearchGuildGossipRpcPullByConfig(
|
||||
this,
|
||||
guildId,
|
||||
query,
|
||||
opts,
|
||||
requestId
|
||||
)
|
||||
},
|
||||
|
||||
async _fetchGuildSearchFromMeshOnce (guildId, query, opts = {}) {
|
||||
|
||||
Reference in New Issue
Block a user