-
Notifications
You must be signed in to change notification settings - Fork 187
Plugin Support for Java SDK #2761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
donald-pinckney
wants to merge
26
commits into
master
Choose a base branch
from
d/plugins
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e3a93a4
Initial version
donald-pinckney 3295876
remove discovery, update notes
donald-pinckney 873867d
remove notes
donald-pinckney bd48697
Add initializeWorker in plugin interface.
donald-pinckney 25e9e07
Re-do shutdownWorkerFactory design with chain
donald-pinckney 06f5fd2
rename runWorkerFactory -> startWorkerFactory
donald-pinckney 2db0acc
Move plugins around
donald-pinckney 8e161ec
add startWorker and shutdownWorker
donald-pinckney e6b4a8d
rename again
donald-pinckney f36ac27
Improved SimplePlugin builder design
donald-pinckney d7a7254
Remove default implementations, and add in startWorkerFactory and shu…
donald-pinckney db499d6
Don't return the builders
donald-pinckney 0414913
Remove ServiceStubsSupplier and checked exception
donald-pinckney 377d00d
Cleanup applyClientPluginConfiguration
donald-pinckney d7f9bd3
array instead of list
donald-pinckney b2957dd
Require ClientPlugin in WorkflowClientOptions
donald-pinckney 7465568
Seaparate out WorkflowClientPlugin and WorkflowServiceStubsPlugin
donald-pinckney c9f70eb
Lift up to a generic ServiceStubsPlugin
donald-pinckney f35439f
Add ScheduleClientPlugin, and rename WorkflowClientPlugin.configureCl…
donald-pinckney 219f0cd
Remove ServiceStubsPlugin super interface
donald-pinckney cfbe494
Document order of validation and plugin application
donald-pinckney 8a5d85f
abstract SimplePlugin
donald-pinckney 19fb453
Add data converters, activities, workflows, Nexus services
donald-pinckney 1fc6deb
bug fix
donald-pinckney 715085e
Add duplicate warnings
donald-pinckney 16a89f5
cleanup tests some
donald-pinckney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
80 changes: 80 additions & 0 deletions
80
temporal-sdk/src/main/java/io/temporal/client/WorkflowClientPlugin.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
| * | ||
| * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this material except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.temporal.client; | ||
|
|
||
| import io.temporal.common.Experimental; | ||
| import io.temporal.common.SimplePlugin; | ||
| import javax.annotation.Nonnull; | ||
|
|
||
| /** | ||
| * Plugin interface for customizing Temporal workflow client configuration. | ||
| * | ||
| * <p>This interface is separate from {@link | ||
| * io.temporal.serviceclient.WorkflowServiceStubs.ServiceStubsPlugin} to allow plugins that only | ||
| * need to configure the workflow client without affecting the underlying gRPC connection. | ||
| * | ||
| * <p>Plugins that implement both {@code ServiceStubsPlugin} and {@code WorkflowClientPlugin} will | ||
| * have their service stubs configuration applied when creating the service stubs, and their client | ||
| * configuration applied when creating the workflow client. | ||
| * | ||
| * <p>Plugins that also implement {@link io.temporal.worker.WorkerPlugin} are automatically | ||
| * propagated from the client to workers created from that client. | ||
| * | ||
| * <p>Example implementation: | ||
| * | ||
| * <pre>{@code | ||
| * public class LoggingPlugin extends SimplePlugin { | ||
| * public LoggingPlugin() { | ||
| * super("my-org.logging"); | ||
| * } | ||
| * | ||
| * @Override | ||
| * public void configureClient(WorkflowClientOptions.Builder builder) { | ||
| * // Add custom interceptor | ||
| * builder.setInterceptors(new LoggingInterceptor()); | ||
| * } | ||
| * } | ||
| * }</pre> | ||
| * | ||
| * @see io.temporal.serviceclient.WorkflowServiceStubs.ServiceStubsPlugin | ||
| * @see io.temporal.worker.WorkerPlugin | ||
| * @see SimplePlugin | ||
| */ | ||
| @Experimental | ||
| public interface WorkflowClientPlugin { | ||
|
|
||
| /** | ||
| * Returns a unique name for this plugin. Used for logging and duplicate detection. Recommended | ||
| * format: "organization.plugin-name" (e.g., "io.temporal.tracing") | ||
| * | ||
| * @return fully qualified plugin name | ||
| */ | ||
| @Nonnull | ||
| String getName(); | ||
|
|
||
| /** | ||
| * Allows the plugin to modify workflow client options before the client is created. Called during | ||
| * configuration phase in forward (registration) order. | ||
| * | ||
| * @param builder the options builder to modify | ||
| */ | ||
| void configureWorkflowClient(@Nonnull WorkflowClientOptions.Builder builder); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cretz One subtle thing here with plugin propagation is what the plugins see, for which plugins are set on the builder when
plugin.configureWorkflowClient(builder)is called on the plugin.In this Java implementation, the plugins will all see the
mergedPlugins(propagated + explicit).In Python, the plugins only see the plugins that are in the explicit config, and not the propagated ones:
(that code is for _worker.py, but point still stands).
Do you have an intuition for which is the correct behavior and why? I would think that the Java behavior is more natural.