Skip to content

Add close() and flush() lifecycle methods to StackAdapter and Stack #5

@cuibonobo

Description

@cuibonobo

The StackAdapter interface and Stack class have no way to signal shutdown or flush pending writes. This is needed before the API adapter can be built, since it will maintain an offline write queue that needs to be committed cleanly.

Changes needed

In packages/core/src/types.ts, add two optional lifecycle methods to StackAdapter:

  • flush?(): Promise<void> — flush any pending writes (e.g. offline queue). No-op for adapters that write immediately.
  • close?(): Promise<void> — release any held resources (connections, file handles, timers).

In packages/core/src/stack.ts, add corresponding public methods that delegate to the adapter:

  • stack.flush() — delegates to adapter.flush() if implemented
  • stack.close() — delegates to adapter.close() if implemented

Both methods should be graceful no-ops when the adapter doesn’t implement them.

Notes

  • Tests should be added to stack.test.ts covering both the delegating behavior and the graceful no-op case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions