Skip to content

Commit

Permalink
feat: Flag to fully disable pubsub and all cross-node syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
stbrody committed Oct 11, 2024
1 parent bcc6585 commit a1e9935
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/cli/src/ceramic-daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export function makeCeramicConfig(opts: DaemonConfig): CeramicConfig {
syncOverride: SYNC_OPTIONS_MAP[opts.node.syncOverride],
streamCacheLimit: opts.node.streamCacheLimit,
indexing: opts.indexing,
disablePeerDataSync: opts.ipfs.disablePeerDataSync,
disablePeerDataSync:
opts.ipfs.disablePeerDataSync || process.env.CERAMIC_DISABLE_PEER_DATA_SYNC == 'true',
metrics: opts.metrics,
}
if (opts.stateStore?.mode == StateStoreMode.FS) {
Expand Down
11 changes: 5 additions & 6 deletions packages/core/src/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class Dispatcher {
const rustCeramic = EnvironmentUtils.useRustCeramic()
this.enableSync = rustCeramic ? false : enableSync

if (!rustCeramic) {
if (!this.enableSync) {
const pubsub = new Pubsub(
_ipfs,
topic,
Expand Down Expand Up @@ -178,10 +178,9 @@ export class Dispatcher {
}

async init() {
if (EnvironmentUtils.useRustCeramic()) {
return
if (this.enableSync) {
this.messageBus.subscribe(this.handleMessage.bind(this))
}
this.messageBus.subscribe(this.handleMessage.bind(this))
}

get shutdownSignal(): ShutdownSignal {
Expand Down Expand Up @@ -498,7 +497,7 @@ export class Dispatcher {
* @param tip - Commit CID
*/
publishTip(streamId: StreamID, tip: CID, model?: StreamID): Subscription {
if (process.env.CERAMIC_DISABLE_PUBSUB_UPDATES == 'true' || EnvironmentUtils.useRustCeramic()) {
if (process.env.CERAMIC_DISABLE_PUBSUB_UPDATES == 'true' || !this.enableSync) {
return empty().subscribe()
}

Expand Down Expand Up @@ -621,7 +620,7 @@ export class Dispatcher {
* Gracefully closes the Dispatcher.
*/
async close(): Promise<void> {
if (!EnvironmentUtils.useRustCeramic()) {
if (this.enableSync) {
this.messageBus.unsubscribe()
}
await this.tasks.onIdle()
Expand Down

0 comments on commit a1e9935

Please sign in to comment.