> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AsyncService

> API reference for AsyncService configuration schema including replicas, rollout strategy, and worker config.

<Note>
  ### Note

  While using TrueFoundry python SDK `type` is not a required field in any of the imported classes
</Note>

## AsyncService

### Description

Describes the configuration for the async-service

### Schema

<CodeGroup>
  ```json JSON lines theme={"dark"}
  {
    "type": "string",
    "replicas": 1,
    "rollout_strategy": {
      "type": "string",
      "max_unavailable_percentage": 25,
      "max_surge_percentage": 0
    },
    "worker_config": {
      "input_config": {
        "type": "string",
        "queue_url": "string",
        "region_name": "string",
        "visibility_timeout": 0,
        "wait_time_seconds": 19,
        "auth": {
          "aws_access_key_id": "string",
          "aws_secret_access_key": "string",
          "aws_session_token": "string"
        }
      },
      "output_config": {
        "type": "string",
        "queue_url": "string",
        "region_name": "string",
        "auth": {
          "aws_access_key_id": "string",
          "aws_secret_access_key": "string",
          "aws_session_token": "string"
        }
      }
    }
  }
  ```
</CodeGroup>

### Properties

| Name              | Type                               | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ----------------- | ---------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type              | string                             | false    | +value=async-service                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| replicas          | any                                | false    | Replicas of service you want to run                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| rollout\_strategy | [Rolling](/docs/asyncservice)      | false    | This strategy updates the pods in a rolling fashion such that a subset of the total pods are replaced with new version at one time. A commonly used strategy can be to have maxUnavailablePercentage close to 0 so that there is no downtime and keep the maxSurgePercentage to around 25%. If you are anyways running a large number of pods, the service can often tolerate a few pods going down - so you max maxUnavailablePercentage = 10 and maxSurgePercentage=0. You can read about it more [here](https://spot.io/resources/kubernetes-autoscaling/5-kubernetes-deployment-strategies-roll-out-like-the-pros/) |
| worker\_config    | [WorkerConfig](/docs/asyncservice) | false    | Describes the configuration for the Worker Config                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

## AsyncServiceAutoscaling

### Description

Describes an Async Service Autoscaling configuration

### Schema

<CodeGroup>
  ```json JSON lines theme={"dark"}
  {
    "metrics": {
      "type": "string",
      "queue_length": 0
    }
  }
  ```
</CodeGroup>

### Properties

| Name    | Type                                       | Required | Description                                |
| ------- | ------------------------------------------ | -------- | ------------------------------------------ |
| metrics | [SQSQueueMetricConfig](/docs/asyncservice) | false    | Describes a SQS Queue Metric Configuration |

***

## WorkerConfig

### Description

Describes the configuration for the Worker Config

### Schema

<CodeGroup>
  ```json JSON lines theme={"dark"}
  {
    "input_config": {
      "type": "string",
      "queue_url": "string",
      "region_name": "string",
      "visibility_timeout": 0,
      "wait_time_seconds": 19,
      "auth": {
        "aws_access_key_id": "string",
        "aws_secret_access_key": "string",
        "aws_session_token": "string"
      }
    },
    "output_config": {
      "type": "string",
      "queue_url": "string",
      "region_name": "string",
      "auth": {
        "aws_access_key_id": "string",
        "aws_secret_access_key": "string",
        "aws_session_token": "string"
      }
    }
  }
  ```
</CodeGroup>

### Properties

| Name           | Type                                  | Required | Description                                           |
| -------------- | ------------------------------------- | -------- | ----------------------------------------------------- |
| input\_config  | [SQSInputConfig](/docs/asyncservice)  | true     | Describes the configuration for the input SQS worker  |
| output\_config | [SQSOutputConfig](/docs/asyncservice) | true     | Describes the configuration for the output SQS worker |

## SQSInputConfig

### Description

Describes the configuration for the input SQS worker

### Schema

<CodeGroup>
  ```json JSON lines theme={"dark"}
  {
    "type": "string",
    "queue_url": "string",
    "region_name": "string",
    "visibility_timeout": 0,
    "wait_time_seconds": 19,
    "auth": {
      "aws_access_key_id": "string",
      "aws_secret_access_key": "string",
      "aws_session_token": "string"
    }
  }
  ```
</CodeGroup>

### Properties

| Name                | Type                                   | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------- | -------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type                | string                                 | true     | +value=sqs                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| queue\_url          | string                                 | true     | AWS SQS Queue URL of Subscriber                                                                                                                                                                                                                                                                                                                                                                                                                         |
| region\_name        | string                                 | true     | AWS Region Name                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| visibility\_timeout | integer                                | true     | A period during which Amazon SQS prevents all consumers from receiving and processing the message. If one message takes 5 seconds to process, you can set this number to 7 or any number higher than 5. This will ensure that while the message is being processed, it will not be available to other replicas. For more information, see[here](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) |
| wait\_time\_seconds | integer                                | true     | Wait timeout for long polling. For more information, see[here](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html)                                                                                                                                                                                                                                                                              |
| auth                | [AWSAccessKeyAuth](/docs/asyncservice) | true     | AWS Access Key based Authentication for Basic Service Authentication                                                                                                                                                                                                                                                                                                                                                                                    |

## SQSOutputConfig

### Description

Describes the configuration for the output SQS worker

### Schema

<CodeGroup>
  ```json JSON lines theme={"dark"}
  {
    "type": "string",
    "queue_url": "string",
    "region_name": "string",
    "auth": {
      "aws_access_key_id": "string",
      "aws_secret_access_key": "string",
      "aws_session_token": "string"
    }
  }
  ```
</CodeGroup>

### Properties

| Name         | Type                                   | Required | Description                                                          |
| ------------ | -------------------------------------- | -------- | -------------------------------------------------------------------- |
| type         | string                                 | true     | +value=sqs                                                           |
| queue\_url   | string                                 | true     | AWS SQS Queue URL of Publisher                                       |
| region\_name | string                                 | true     | AWS Region Name                                                      |
| auth         | [AWSAccessKeyAuth](/docs/asyncservice) | true     | AWS Access Key based Authentication for Basic Service Authentication |

## SQSQueueMetricConfig

### Description

Describes a SQS Queue Metric Configuration

### Schema

<CodeGroup>
  ```json JSON lines theme={"dark"}
  {
    "type": "string",
    "queue_length": 0
  }
  ```
</CodeGroup>

### Properties

| Name          | Type    | Required | Description                                                                                                                                                                                                                             |
| ------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type          | string  | true     | +value=sqs                                                                                                                                                                                                                              |
| queue\_length | integer | true     | Upper limit of the number of backlog messages the auto-scaler will try to maintain per replica. If you set this number to 10 and have 30 messages in the queue and one replica, the auto-scaler will scale the number of replicas to 3. |

## AWSAccessKeyAuth

### Description

AWS Access Key based Authentication for Basic Service Authentication

### Schema

<CodeGroup>
  ```json JSON lines theme={"dark"}
  {
    "aws_access_key_id": "string",
    "aws_secret_access_key": "string",
    "aws_session_token": "string"
  }
  ```
</CodeGroup>

### Properties

| Name                     | Type   | Required | Description                                                       |
| ------------------------ | ------ | -------- | ----------------------------------------------------------------- |
| aws\_access\_key\_id     | string | true     | AWS Access Key ID                                                 |
| aws\_secret\_access\_key | string | true     | AWS Secret Access Key for the user to authenticate with           |
| aws\_session\_token      | string | false    | AWS Session Token, only required when using temporary credentials |

***
