From 699b42ac7311212629fb716731ab15514c87a851 Mon Sep 17 00:00:00 2001 From: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:38:52 -0400 Subject: [PATCH] Enable stream-stype serialization for Java Communication Job Router (#29328) --- .../Communication.JobRouter/models.tsp | 53 ++----------------- .../Communication.JobRouter/tspconfig.yaml | 3 +- 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/specification/communication/Communication.JobRouter/models.tsp b/specification/communication/Communication.JobRouter/models.tsp index 51bc6a213b74..4a171d7ee496 100644 --- a/specification/communication/Communication.JobRouter/models.tsp +++ b/specification/communication/Communication.JobRouter/models.tsp @@ -353,7 +353,6 @@ union WorkerSelectorAttachmentKind { weightedAllocation: "weightedAllocation", } -@clientName("ClassificationPolicyInternal", "java") @resource("routing/classificationPolicies") @doc("A container for the rules that govern how jobs are classified.") model ClassificationPolicy { @@ -380,7 +379,6 @@ model ClassificationPolicy { workerSelectorAttachments?: WorkerSelectorAttachment[]; } -@clientName("RouterRuleInternal", "java") @doc(""" A rule of one of the following types: StaticRule: A rule providing static rules that always return the same result, regardless of input. @@ -395,7 +393,6 @@ model RouterRule { kind: RouterRuleKind; } -@clientName("DistributionPolicyInternal", "java") @resource("routing/distributionPolicies") @doc("Policy governing how jobs are distributed to workers") model DistributionPolicy { @@ -416,7 +413,6 @@ model DistributionPolicy { mode?: DistributionMode; } -@clientName("DistributionModeInternal", "java") @doc("Abstract base class for defining a distribution mode.") @discriminator("kind") model DistributionMode { @@ -433,7 +429,6 @@ model DistributionMode { kind: DistributionModeKind; } -@clientName("ExceptionPolicyInternal", "java") @resource("routing/exceptionPolicies") @doc("A policy that defines actions to execute when exception are triggered.") model ExceptionPolicy { @@ -451,7 +446,6 @@ model ExceptionPolicy { exceptionRules?: ExceptionRule[]; } -@clientName("ExceptionRuleInternal", "java") @doc("A rule that defines actions to execute upon a specific trigger.") model ExceptionRule { @doc("Id of an exception rule.") @@ -464,7 +458,6 @@ model ExceptionRule { actions: ExceptionAction[]; } -@clientName("ExceptionTriggerInternal", "java") @doc("Abstract base class for defining a trigger for exception rules.") @discriminator("kind") model ExceptionTrigger { @@ -481,7 +474,6 @@ model RouterJobNote { addedAt?: utcDateTime; } -@clientName("RouterJobInternal", "java") @resource("routing/jobs") @doc("A unit of work to be routed") model RouterJob { @@ -548,7 +540,6 @@ model RouterJob { matchingMode?: JobMatchingMode; } -@clientName("RouterWorkerSelectorInternal", "java") @doc("Describes a condition that must be met against a set of labels for worker selection.") model RouterWorkerSelector { @doc("The label key to query against.") @@ -598,7 +589,6 @@ model RouterJobAssignment { closedAt?: utcDateTime; } -@clientName("JobMatchingModeInternal", "java") @doc(""" A matching mode of one of the following types: QueueAndMatchMode: Used when matching worker to a job is required to be done right after job is queued. @@ -611,7 +601,6 @@ model JobMatchingMode { kind: JobMatchingModeKind; } -@clientName("ScheduleAndSuspendModeInternal", "java") @doc("Describes a matching mode used for scheduling jobs to be queued at a future time. At the specified time, matching worker to a job will not start automatically.") model ScheduleAndSuspendMode extends JobMatchingMode { @doc("Requested schedule time.") @@ -621,22 +610,20 @@ model ScheduleAndSuspendMode extends JobMatchingMode { kind: JobMatchingModeKind.scheduleAndSuspend; } -@clientName("QueueAndMatchModeInternal", "java") @doc("Describes a matching mode where matching worker to a job is automatically started after job is queued successfully.") model QueueAndMatchMode extends JobMatchingMode { @doc("The type discriminator describing QueueAndMatchMode") kind: JobMatchingModeKind.queueAndMatch; } -@clientName("SuspendModeInternal", "java") @doc("Describes a matching mode where matching worker to a job is suspended.") model SuspendMode extends JobMatchingMode { @doc("The type discriminator describing SuspendMode") kind: JobMatchingModeKind.suspend; } -@clientName("CancelJobOptionsInternal", "java") @access(Access.public, "python") +@access(Access.public, "java") @doc("Request payload for cancelling a job.") model CancelJobOptions { @doc("A note that will be appended to a job's Notes collection with the current timestamp.") @@ -646,16 +633,16 @@ model CancelJobOptions { dispositionCode?: string; } -@clientName("CompleteJobOptionsInternal", "java") @access(Access.public, "python") +@access(Access.public, "java") @doc("Request payload for completing jobs.") model CompleteJobOptions { @doc("A note that will be appended to a job's Notes collection with the current timestamp.") note?: string; } -@clientName("CloseJobOptionsInternal", "java") @access(Access.public, "python") +@access(Access.public, "java") @doc("Request payload for closing jobs") model CloseJobOptions { @doc("Indicates the outcome of a job, populate this field with your own custom values.") @@ -713,15 +700,14 @@ model AcceptJobOfferResult { workerId: string; } -@clientName("DeclineJobOfferOptionsInternal", "java") @access(Access.public, "python") +@access(Access.public, "java") @doc("Request payload for declining offers.") model DeclineJobOfferOptions { @doc("If the RetryOfferAt is not provided, then this job will not be offered again to the worker who declined this job unless the worker is de-registered and re-registered. If a RetryOfferAt time is provided, then the job will be re-matched to eligible workers at the retry time in UTC. The worker that declined the job will also be eligible for the job at that time.") retryOfferAt?: utcDateTime; } -@clientName("RouterQueueInternal", "java") @resource("routing/queues") @doc("A queue that can contain jobs to be routed.") model RouterQueue { @@ -746,7 +732,6 @@ model RouterQueue { exceptionPolicyId?: string; } -@clientName("RouterQueueStatisticsInternal", "java") @doc("Statistics for the queue.") model RouterQueueStatistics { @doc("Id of the queue these details are about.") @@ -762,7 +747,6 @@ model RouterQueueStatistics { longestJobWaitTimeMinutes?: float64; } -@clientName("RouterWorkerInternal", "java") @resource("routing/workers") @doc("An entity for jobs to be routed to.") model RouterWorker { @@ -863,7 +847,6 @@ model RouterWorkerAssignment { assignedAt: utcDateTime; } -@clientName("BestWorkerModeInternal", "java") @doc("Jobs are distributed to the worker with the strongest abilities available.") model BestWorkerMode extends DistributionMode { @doc("Define a scoring rule to use, when calculating a score to determine the best worker. If not set, will use a default scoring formula that uses the number of job labels that the worker labels match, as well as the number of label selectors the worker labels match and/or exceed using a logistic function (https://en.wikipedia.org/wiki/Logistic_function).") @@ -894,7 +877,6 @@ model ScoringRuleOptions { descendingOrder?: boolean = true; } -@clientName("CancelExceptionActionInternal", "java") @doc("An action that marks a job as cancelled.") model CancelExceptionAction extends ExceptionAction { @doc("A note that will be appended to a job's notes collection with the current timestamp.") @@ -907,7 +889,6 @@ model CancelExceptionAction extends ExceptionAction { kind: ExceptionActionKind.cancel; } -@clientName("ExceptionActionInternal", "java") @doc("The action to take when the exception is triggered.") @discriminator("kind") model ExceptionAction { @@ -918,7 +899,6 @@ model ExceptionAction { kind: ExceptionActionKind; } -@clientName("ConditionalQueueSelectorAttachmentInternal", "java") @doc("Describes a set of queue selectors that will be attached if the given condition resolves to true.") model ConditionalQueueSelectorAttachment extends QueueSelectorAttachment { @doc("The condition that must be true for the queue selectors to be attached.") @@ -931,7 +911,6 @@ model ConditionalQueueSelectorAttachment extends QueueSelectorAttachment { kind: QueueSelectorAttachmentKind.conditional; } -@clientName("RouterQueueSelectorInternal", "java") @doc("Describes a condition that must be met against a set of labels for queue selection.") model RouterQueueSelector { @doc("The label key to query against.") @@ -945,7 +924,6 @@ model RouterQueueSelector { value?: unknown; } -@clientName("QueueSelectorAttachmentInternal", "java") @doc("An attachment of queue selectors to resolve a queue to a job from a classification policy.") @discriminator("kind") model QueueSelectorAttachment { @@ -953,7 +931,6 @@ model QueueSelectorAttachment { kind: QueueSelectorAttachmentKind; } -@clientName("ConditionalWorkerSelectorAttachmentInternal", "java") @doc("Describes a set of worker selectors that will be attached if the given condition resolves to true.") model ConditionalWorkerSelectorAttachment extends WorkerSelectorAttachment { @doc("The condition that must be true for the worker selectors to be attached.") @@ -966,7 +943,6 @@ model ConditionalWorkerSelectorAttachment extends WorkerSelectorAttachment { kind: WorkerSelectorAttachmentKind.conditional; } -@clientName("WorkerSelectorAttachmentInternal", "java") @doc("An attachment which attaches worker selectors to a job.") @discriminator("kind") model WorkerSelectorAttachment { @@ -974,14 +950,12 @@ model WorkerSelectorAttachment { kind: WorkerSelectorAttachmentKind; } -@clientName("DirectMapRouterRuleInternal", "java") @doc("A rule that return the same labels as the input labels.") model DirectMapRouterRule extends RouterRule { @doc("The type discriminator describing a sub-type of Rule.") kind: RouterRuleKind.directMap; } -@clientName("ExpressionRouterRuleInternal", "java") @doc("A rule providing inline expression rules.") model ExpressionRouterRule extends RouterRule { @doc("The expression language to compile to and execute.") @@ -994,7 +968,6 @@ model ExpressionRouterRule extends RouterRule { kind: RouterRuleKind.expression; } -@clientName("FunctionRouterRuleInternal", "java") @doc("A rule providing a binding to an HTTP Triggered Azure Function.") model FunctionRouterRule extends RouterRule { @doc("URL for Azure Function.") @@ -1019,14 +992,12 @@ model FunctionRouterRuleCredential { clientId?: string; } -@clientName("LongestIdleModeInternal", "java") @doc("Jobs are directed to the worker who has been idle longest.") model LongestIdleMode extends DistributionMode { @doc("The type discriminator describing a sub-type of Mode.") kind: DistributionModeKind.longestIdle; } -@clientName("ManualReclassifyExceptionActionInternal", "java") @doc("An action that manually reclassifies a job by providing the queue, priority and worker selectors.") model ManualReclassifyExceptionAction extends ExceptionAction { @doc("Updated QueueId.") @@ -1052,7 +1023,6 @@ model OAuth2WebhookClientCredential { clientSecret?: string; } -@clientName("PassThroughQueueSelectorAttachmentInternal", "java") @doc("Attaches a queue selector where the value is passed through from a job's label with the same key.") model PassThroughQueueSelectorAttachment extends QueueSelectorAttachment { @doc("The label key to query against.") @@ -1065,7 +1035,6 @@ model PassThroughQueueSelectorAttachment extends QueueSelectorAttachment { kind: QueueSelectorAttachmentKind.passThrough; } -@clientName("PassThroughWorkerSelectorAttachmentInternal", "java") @doc("Attaches a worker selector where the value is passed through from a job's label with the same key.") model PassThroughWorkerSelectorAttachment extends WorkerSelectorAttachment { @doc("The label key to query against.") @@ -1081,7 +1050,6 @@ model PassThroughWorkerSelectorAttachment extends WorkerSelectorAttachment { kind: WorkerSelectorAttachmentKind.passThrough; } -@clientName("QueueLengthExceptionTriggerInternal", "java") @doc("Trigger for an exception action on exceeding queue length.") model QueueLengthExceptionTrigger extends ExceptionTrigger { @doc("Threshold of number of jobs ahead in the queue to for this trigger to fire.") @@ -1091,7 +1059,6 @@ model QueueLengthExceptionTrigger extends ExceptionTrigger { kind: ExceptionTriggerKind.queueLength; } -@clientName("QueueWeightedAllocationInternal", "java") @doc("Contains the weight percentage and queue selectors to be applied if selected for weighted distributions.") model QueueWeightedAllocation { @doc("The percentage of this weight, expressed as a fraction of 1.") @@ -1101,7 +1068,6 @@ model QueueWeightedAllocation { queueSelectors: RouterQueueSelector[]; } -@clientName("ReclassifyExceptionActionInternal", "java") @doc("An action that modifies labels on a job and then reclassifies it.") model ReclassifyExceptionAction extends ExceptionAction { @doc("The new classification policy that will determine queue, priority and worker selectors.") @@ -1115,14 +1081,12 @@ model ReclassifyExceptionAction extends ExceptionAction { kind: ExceptionActionKind.reclassify; } -@clientName("RoundRobinModeInternal", "java") @doc("Jobs are distributed in order to workers, starting with the worker that is after the last worker to receive a job.") model RoundRobinMode extends DistributionMode { @doc("The type discriminator describing a sub-type of Mode.") kind: DistributionModeKind.roundRobin; } -@clientName("RuleEngineQueueSelectorAttachmentInternal", "java") @doc("Attaches queue selectors to a job when the RouterRule is resolved.") model RuleEngineQueueSelectorAttachment extends QueueSelectorAttachment { @doc("A RouterRule that resolves a collection of queue selectors to attach.") @@ -1132,7 +1096,6 @@ model RuleEngineQueueSelectorAttachment extends QueueSelectorAttachment { kind: QueueSelectorAttachmentKind.ruleEngine; } -@clientName("RuleEngineWorkerSelectorAttachmentInternal", "java") @doc("Attaches worker selectors to a job when a RouterRule is resolved.") model RuleEngineWorkerSelectorAttachment extends WorkerSelectorAttachment { @doc("A RouterRule that resolves a collection of worker selectors to attach.") @@ -1142,7 +1105,6 @@ model RuleEngineWorkerSelectorAttachment extends WorkerSelectorAttachment { kind: WorkerSelectorAttachmentKind.ruleEngine; } -@clientName("StaticQueueSelectorAttachmentInternal", "java") @doc("Describes a queue selector that will be attached to a job.") model StaticQueueSelectorAttachment extends QueueSelectorAttachment { @doc("The queue selector to attach.") @@ -1152,7 +1114,6 @@ model StaticQueueSelectorAttachment extends QueueSelectorAttachment { kind: QueueSelectorAttachmentKind.static; } -@clientName("StaticRouterRuleInternal", "java") @doc("A rule providing static rules that always return the same result, regardless of input.") model StaticRouterRule extends RouterRule { #suppress "@azure-tools/typespec-azure-core/no-unknown" "Unions are currently not allowed in spec." @@ -1163,7 +1124,6 @@ model StaticRouterRule extends RouterRule { kind: RouterRuleKind.static; } -@clientName("StaticWorkerSelectorAttachmentInternal", "java") @doc("Describes a worker selector that will be attached to a job.") model StaticWorkerSelectorAttachment extends WorkerSelectorAttachment { @doc("The worker selector to attach.") @@ -1173,7 +1133,6 @@ model StaticWorkerSelectorAttachment extends WorkerSelectorAttachment { kind: WorkerSelectorAttachmentKind.static; } -@clientName("WaitTimeExceptionTriggerInternal", "java") @doc("Trigger for an exception action on exceeding wait time.") model WaitTimeExceptionTrigger extends ExceptionTrigger { @doc("Threshold for wait time for this trigger.") @@ -1183,7 +1142,6 @@ model WaitTimeExceptionTrigger extends ExceptionTrigger { kind: ExceptionTriggerKind.waitTime; } -@clientName("WebhookRouterRuleInternal", "java") @doc("A rule providing a binding to an external web server.") model WebhookRouterRule extends RouterRule { @doc("Uri for Authorization Server.") @@ -1199,7 +1157,6 @@ model WebhookRouterRule extends RouterRule { kind: RouterRuleKind.webhook; } -@clientName("WeightedAllocationQueueSelectorAttachmentInternal", "java") @doc("Describes multiple sets of queue selectors, of which one will be selected and attached according to a weighting.") model WeightedAllocationQueueSelectorAttachment extends QueueSelectorAttachment { @@ -1210,7 +1167,6 @@ model WeightedAllocationQueueSelectorAttachment kind: QueueSelectorAttachmentKind.weightedAllocation; } -@clientName("WeightedAllocationWorkerSelectorAttachmentInternal", "java") @doc("Describes multiple sets of worker selectors, of which one will be selected and attached according to a weighting.") model WeightedAllocationWorkerSelectorAttachment extends WorkerSelectorAttachment { @@ -1221,7 +1177,6 @@ model WeightedAllocationWorkerSelectorAttachment kind: WorkerSelectorAttachmentKind.weightedAllocation; } -@clientName("WorkerWeightedAllocationInternal", "java") @doc("Contains the weight percentage and worker selectors to be applied if selected for weighted distributions.") model WorkerWeightedAllocation { @doc("The percentage of this weight, expressed as a fraction of 1.") diff --git a/specification/communication/Communication.JobRouter/tspconfig.yaml b/specification/communication/Communication.JobRouter/tspconfig.yaml index 54372a371083..2b99d766d271 100644 --- a/specification/communication/Communication.JobRouter/tspconfig.yaml +++ b/specification/communication/Communication.JobRouter/tspconfig.yaml @@ -48,10 +48,9 @@ options: partial-update: true service-name: JobRouter custom-types-subpackage: "implementation.models" - custom-types: "BestWorkerModeInternal,CancelExceptionActionInternal,ClassificationPolicyInternal,ConditionalQueueSelectorAttachmentInternal,ConditionalWorkerSelectorAttachmentInternal,DirectMapRouterRuleInternal,DistributionModeInternal,DistributionPolicyInternal,ExceptionActionInternal,ExceptionPolicyInternal,ExceptionRuleInternal,ExceptionTriggerInternal,ExpressionRouterRuleInternal,FunctionRouterRuleInternal,LongestIdleModeInternal,ManualReclassifyExceptionActionInternal,PassThroughQueueSelectorAttachmentInternal,PassThroughWorkerSelectorAttachmentInternal,QueueLengthExceptionTriggerInternal,QueueSelectorAttachmentInternal,QueueWeightedAllocationInternal,ReclassifyExceptionActionInternal,RoundRobinModeInternal,RouterJobInternal,RouterQueueInternal,RouterQueueSelectorInternal,RouterQueueStatisticsInternal,RouterRuleInternal,RouterWorkerInternal,RouterWorkerSelectorInternal,RuleEngineQueueSelectorAttachmentInternal,RuleEngineWorkerSelectorAttachmentInternal,StaticQueueSelectorAttachmentInternal,StaticRouterRuleInternal,StaticWorkerSelectorAttachmentInternal,WaitTimeExceptionTriggerInternal,WebhookRouterRuleInternal,WeightedAllocationQueueSelectorAttachmentInternal,WeightedAllocationWorkerSelectorAttachmentInternal,WorkerSelectorAttachmentInternal,WorkerWeightedAllocationInternal,CancelJobOptionsInternal,CancelJobResultInternal,CloseJobOptionsInternal,CloseJobResultInternal,CompleteJobOptionsInternal,CompleteJobResultInternal,DeclineJobOfferOptionsInternal,DeclineJobOfferResultInternal,ReclassifyJobOptionsInternal,ReclassifyJobResultInternal,JobMatchingModeInternal,SuspendModeInternal,QueueAndMatchModeInternal,ScheduleAndSuspendModeInternal" + custom-types: "CancelJobResultInternal,CloseJobResultInternal,CompleteJobResultInternal,DeclineJobOfferResultInternal,ReclassifyJobOptionsInternal,ReclassifyJobResultInternal" customization-class: customization/src/main/java/JobRouterSdkCustomization.java flavor: azure - stream-style-serialization: false "@azure-tools/typespec-ts": emitter-output-dir: "{js-sdk-folder}/sdk/{service-directory-name}/communication-job-router-rest" package-dir: "communication-job-router-rest"