Add withWorkerAndClient convenience to TemporalTestServer#144
Open
RalucaP wants to merge 2 commits into
Open
Conversation
Merged
6ddcd5e to
028b802
Compare
FranzBusch
reviewed
May 12, 2026
| activities: [any ActivityDefinition] = [], | ||
| workflows: [any WorkflowDefinition.Type] = [], | ||
| namespace: String = "default", | ||
| interceptors: [any WorkerInterceptor] = [], |
Member
There was a problem hiding this comment.
Suggested change
| interceptors: [any WorkerInterceptor] = [], | |
| workerInterceptors: [any WorkerInterceptor] = [], |
| logger.logLevel = .info | ||
| return logger | ||
| }(), | ||
| _ body: sending @escaping @isolated(any) (String, TemporalClient) async throws -> sending Result |
Member
There was a problem hiding this comment.
Can this closure actually be nonisolated(nonseding) instead of sending @escaping @isolated(any)?
028b802 to
ea2d688
Compare
Combines withConnectedWorker and withConnectedClient into a single call that handles worker configuration and task queue generation internally.
Replaces the manual withConnectedWorker + withConnectedClient nesting in the integration and time-skipping examples with the new helper.
ea2d688 to
6be93eb
Compare
FranzBusch
requested changes
May 27, 2026
| logger.logLevel = .info | ||
| return logger | ||
| }(), | ||
| _ body: nonisolated(nonsending) (String, TemporalClient) async throws -> sending Result |
Member
There was a problem hiding this comment.
nonisolated(nonsending) is enabled by default in this repo. Also we don't need the Result type to be sending.
Suggested change
| _ body: nonisolated(nonsending) (String, TemporalClient) async throws -> sending Result | |
| body: (String, TemporalClient) async throws -> Result |
| /// - body: An async closure that receives the task queue name and a connected client. | ||
| /// - Returns: The value returned by `body`. | ||
| /// - Throws: Any error thrown while creating the worker, connecting the client, or by the `body` closure. | ||
| public func withWorkerAndClient<Result: Sendable>( |
Member
There was a problem hiding this comment.
Suggested change
| public func withWorkerAndClient<Result: Sendable>( | |
| public func withWorkerAndClient<Result>( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #143.
Motivation
Integration tests require nesting
withConnectedWorkerandwithConnectedClientplus creating aTemporalWorker.Configurationby hand every time.Modifications
withWorkerAndClientonTemporalTestServerthat creates a worker config with a unique task queue, starts the worker, connects a client, and passes(taskQueue, client)to the closure.Result
The common integration test setup is a single call. Testing docs are 34 lines shorter as a result.
Test Plan
Added a test covering workflow execution through the helper. Updated the testing docs and verified the new examples are correct.