Skip to content

CompositeProvider Class ​

A composite runner provider that implements fallback and distribution strategies.

Initializer ​

ts
import { CompositeProvider } from '@cloudsnorkel/cdk-github-runners'

new CompositeProvider()
python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.CompositeProvider()
java
import com.cloudsnorkel.cdk.github.runners.CompositeProvider;

new CompositeProvider();
csharp
using CloudSnorkel;

new CompositeProvider();
go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.NewCompositeProvider() CompositeProvider

Static Functions ​

distribute()distribute()distribute()Distribute()Distribute() ​

Creates a weighted distribution runner provider that randomly selects a provider based on weights.

For example, given providers A (weight 10), B (weight 20), C (weight 30):

  • Total weight = 60
  • Probability of selecting A = 10/60 = 16.67%
  • Probability of selecting B = 20/60 = 33.33%
  • Probability of selecting C = 30/60 = 50%

You can use this to distribute load across multiple instance types or availability zones.

ts
import { CompositeProvider } from '@cloudsnorkel/cdk-github-runners'

CompositeProvider.distribute(scope: Construct, id: string, weightedProviders: WeightedRunnerProvider[])
  • scope: Construct

    The scope in which to define this construct.

  • id: string

    The scoped construct ID.

  • weightedProviders: WeightedRunnerProvider[]

    List of weighted runner providers.

python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.CompositeProvider.distribute(
  scope: Construct,
  id: str,
  weighted_providers: typing.List[WeightedRunnerProvider]
)
  • scope: Construct

    The scope in which to define this construct.

  • id: str

    The scoped construct ID.

  • weighted_providers: typing.List[WeightedRunnerProvider]

    List of weighted runner providers.

java
import com.cloudsnorkel.cdk.github.runners.CompositeProvider;

CompositeProvider.distribute(Construct scope, java.lang.String id, java.util.List<WeightedRunnerProvider> weightedProviders)
  • scope: Construct

    The scope in which to define this construct.

  • id: java.lang.String

    The scoped construct ID.

  • weightedProviders: java.util.List<WeightedRunnerProvider>

    List of weighted runner providers.

csharp
using CloudSnorkel;

CompositeProvider.Distribute(Construct Scope, string Id, WeightedRunnerProvider[] WeightedProviders);
  • Scope: Construct

    The scope in which to define this construct.

  • Id: string

    The scoped construct ID.

  • WeightedProviders: WeightedRunnerProvider[]

    List of weighted runner providers.

go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.CompositeProvider_Distribute(scope Construct, id *string, weightedProviders *[]WeightedRunnerProvider) ICompositeProvider
  • scope: Construct

    The scope in which to define this construct.

  • id: *string

    The scoped construct ID.

  • weightedProviders: *[]WeightedRunnerProvider

    List of weighted runner providers.

fallback()fallback()fallback()Fallback()Fallback() ​

Creates a fallback runner provider that tries each provider in order until one succeeds.

For example, given providers A, B, C:

  • Try A first
  • If A fails, try B
  • If B fails, try C

You can use this to try spot instance first, and switch to on-demand instances if spot is unavailable.

Or you can use this to try different instance types in order of preference.

ts
import { CompositeProvider } from '@cloudsnorkel/cdk-github-runners'

CompositeProvider.fallback(scope: Construct, id: string, providers: IRunnerProvider[])
  • scope: Construct

    The scope in which to define this construct.

  • id: string

    The scoped construct ID.

  • providers: IRunnerProvider[]

    List of runner providers to try in order.

python
import cloudsnorkel.cdk_github_runners

cloudsnorkel.cdk_github_runners.CompositeProvider.fallback(
  scope: Construct,
  id: str,
  providers: typing.List[IRunnerProvider]
)
  • scope: Construct

    The scope in which to define this construct.

  • id: str

    The scoped construct ID.

  • providers: typing.List[IRunnerProvider]

    List of runner providers to try in order.

java
import com.cloudsnorkel.cdk.github.runners.CompositeProvider;

CompositeProvider.fallback(Construct scope, java.lang.String id, java.util.List<IRunnerProvider> providers)
  • scope: Construct

    The scope in which to define this construct.

  • id: java.lang.String

    The scoped construct ID.

  • providers: java.util.List<IRunnerProvider>

    List of runner providers to try in order.

csharp
using CloudSnorkel;

CompositeProvider.Fallback(Construct Scope, string Id, IRunnerProvider[] Providers);
  • Scope: Construct

    The scope in which to define this construct.

  • Id: string

    The scoped construct ID.

  • Providers: IRunnerProvider[]

    List of runner providers to try in order.

go
import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"

cloudsnorkelcdkgithubrunners.CompositeProvider_Fallback(scope Construct, id *string, providers *[]IRunnerProvider) ICompositeProvider
  • scope: Construct

    The scope in which to define this construct.

  • id: *string

    The scoped construct ID.

  • providers: *[]IRunnerProvider

    List of runner providers to try in order.

Released under the Apache-2.0 License.