Skip to content

refactor(bridge): encapsulate lifecycle registration - #265

Merged
Andiveli merged 1 commit into
betafrom
refactor/go-client-lifecycle
Aug 26, 2026
Merged

refactor(bridge): encapsulate lifecycle registration#265
Andiveli merged 1 commit into
betafrom
refactor/go-client-lifecycle

Conversation

@Andiveli

Copy link
Copy Markdown
Owner

Summary

  • Give QR-channel and event-handler registration lifecycle one synchronized owner.
  • Make repeated connection setup register the WhatsApp event handler only once.

Changes

  • Add mutex-protected lifecycle state for QR and registration state.
  • Reset lifecycle registration when constructing a new client.
  • Preserve existing cgo exports, callback order, reconnect behavior, and the parent ownership contracts.
  • Add focused idempotency and reset coverage.

Testing

  • cargo fmt --check
  • cargo test -- --test-threads=1 (604 passed)
  • Focused lifecycle tests (2 passed)
  • cd whatsrust/lib && go test ./... -count=1
  • cd whatsrust/lib && go vet ./...
  • git diff --check
  • Manual testing: N/A; internal lifecycle extraction.

Chain context

main
└── PR #260: cgo ownership
    └── 📍 refactor/go-client-lifecycle
        └── next: migrate direct client consumers behind accessors
  • Depends on: PR refactor(bridge): make cgo ownership explicit #260 / refactor/go-cgo-ownership.
  • Ends with: idempotent lifecycle registration and owned QR state.
  • Follow-up: migrate selected package-level client consumers without broad event-routing changes.
  • Out of scope: panic mapping, identity policy, outbound builders, and general event routing.
  • Review budget: 78 authored lines.
  • Rollback: revert 9a543c6; only three lifecycle/event-wiring files are affected.

Closes #262

@Andiveli Andiveli added the type:refactor Code refactoring label Aug 26, 2026
@Andiveli
Andiveli changed the base branch from refactor/go-cgo-ownership to beta August 26, 2026 21:13
@Andiveli
Andiveli merged commit d61d37f into beta Aug 26, 2026
1 check passed
@Andiveli
Andiveli deleted the refactor/go-client-lifecycle branch August 31, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant