• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

temporalio / sdk-java / #175

pending completion
#175

push

github-actions

web-flow
Worker / Build Id versioning (#1786)

Implement new worker build id based versioning feature

236 of 236 new or added lines in 24 files covered. (100.0%)

18343 of 23697 relevant lines covered (77.41%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/temporal-sdk/src/main/java/io/temporal/client/WorkerBuildIdVersionSets.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.client;
22

23
import io.temporal.api.workflowservice.v1.GetWorkerBuildIdCompatibilityResponse;
24
import io.temporal.common.Experimental;
25
import java.util.Collections;
26
import java.util.List;
27
import java.util.Optional;
28
import java.util.stream.Collectors;
29

30
/** Represents the sets of compatible Build Ids associated with a particular task queue. */
31
@Experimental
32
public class WorkerBuildIdVersionSets {
33

34
  /** Represents a set of Build Ids which are compatible with one another. */
35
  public static class CompatibleSet {
36
    private final List<String> buildIds;
37

38
    CompatibleSet(List<String> buildIds) {
×
39
      this.buildIds = Collections.unmodifiableList(buildIds);
×
40
    }
×
41

42
    /**
43
     * @return All the Build Ids in the set
44
     */
45
    public List<String> getBuildIds() {
46
      return buildIds;
×
47
    }
48

49
    /**
50
     * @return The default Build Id for this compatible set.
51
     */
52
    public Optional<String> defaultBuildId() {
53
      if (buildIds.isEmpty()) {
×
54
        return Optional.empty();
×
55
      }
56
      return Optional.of(buildIds.get(buildIds.size() - 1));
×
57
    }
58
  }
59

60
  private final List<CompatibleSet> buildIdVersionSets;
61

62
  WorkerBuildIdVersionSets(GetWorkerBuildIdCompatibilityResponse fetchResponse) {
×
63
    buildIdVersionSets =
×
64
        Collections.unmodifiableList(
×
65
            fetchResponse.getMajorVersionSetsList().stream()
×
66
                .map(majorSet -> new CompatibleSet(majorSet.getBuildIdsList()))
×
67
                .collect(Collectors.toList()));
×
68
  }
×
69

70
  /**
71
   * @return the current overall default Build Id for the queue. Returns empty if there are no
72
   *     defined Build Ids.
73
   */
74
  public Optional<String> defaultBuildId() {
75
    CompatibleSet defaultSet = defaultSet();
×
76
    if (defaultSet == null) {
×
77
      return Optional.empty();
×
78
    }
79
    return defaultSet.defaultBuildId();
×
80
  }
81

82
  /**
83
   * @return the current overall default compatible set for the queue. Returns null if there are no
84
   *     defined Build Ids.
85
   */
86
  public CompatibleSet defaultSet() {
87
    if (buildIdVersionSets.isEmpty()) {
×
88
      return null;
×
89
    }
90
    return buildIdVersionSets.get(buildIdVersionSets.size() - 1);
×
91
  }
92

93
  /**
94
   * @return All compatible sets for the queue. The last set in the list is the overall default.
95
   */
96
  public List<CompatibleSet> allSets() {
97
    return buildIdVersionSets;
×
98
  }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc