# JobRecord

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.jobrecord/
> Summary: JobRecord: The summary of a queued job. The header of its items (JobItemRecord).

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

The summary of a queued job. The header of its items ([JobItemRecord](/api/tracon.jobitemrecord/)).

```csharp
public sealed record JobRecord : IEquatable<JobRecord>
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.jobrecord/">JobRecord</a></dd><dt>Implements</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.iequatable-1">IEquatable&lt;JobRecord&gt;</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Constructors

### <a id="Tracon_JobRecord__ctor"></a> JobRecord\(\)

```csharp
public JobRecord()
```

## Properties

### <a id="Tracon_JobRecord_Attempt"></a> Attempt

The number of lease attempts. Increments each time a worker leases the job.

```csharp
public int Attempt { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_JobRecord_CompletedAt"></a> CompletedAt

The completion time (UTC). [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) while the job is in progress.

```csharp
public DateTimeOffset? CompletedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

### <a id="Tracon_JobRecord_CreatedAt"></a> CreatedAt

The creation time (UTC).

```csharp
public required DateTimeOffset CreatedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

### <a id="Tracon_JobRecord_DoneItems"></a> DoneItems

The number of items that completed successfully.

```csharp
public int DoneItems { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_JobRecord_ErrorMessage"></a> ErrorMessage

The failure message. Populated only for [JobStatus.Failed](/api/tracon.jobstatus/).

```csharp
public string? ErrorMessage { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_JobRecord_FailedItems"></a> FailedItems

The number of items that failed.

```csharp
public int FailedItems { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_JobRecord_HandlerKey"></a> HandlerKey

The key of the [IJobHandler](/api/tracon.ijobhandler/) that executes this job. See
[JobHandlerKeys](/api/tracon.jobhandlerkeys/).

```csharp
public required string HandlerKey { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

#### Remarks

Both the job's classification and its dispatch identity; there is no
second field. The worker matches it against the registered keys
ordinally, so a job whose key nobody registered fails with
[JobErrorCodes.UnknownHandlerKey](/api/tracon.joberrorcodes/#Tracon_JobErrorCodes_UnknownHandlerKey) instead of running the
wrong handler.

### <a id="Tracon_JobRecord_Id"></a> Id

The job identifier.

```csharp
public required Guid Id { get; init; }
```

#### Property Value

 [Guid](https://learn.microsoft.com/dotnet/api/system.guid)

### <a id="Tracon_JobRecord_Lane"></a> Lane

The lane this job runs in. See [JobLanes](/api/tracon.joblanes/). A worker only
leases jobs from the lanes it subscribes to
(`TraconSchedulingOptions.Lanes`).

```csharp
public string Lane { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobRecord_LeaseOwner"></a> LeaseOwner

The identifier of the worker currently leasing the job. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if not leased.

```csharp
public string? LeaseOwner { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="Tracon_JobRecord_LeaseUntil"></a> LeaseUntil

The time the current lease expires (UTC). The job may be re-leased once it expires.

```csharp
public DateTimeOffset? LeaseUntil { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

### <a id="Tracon_JobRecord_MaxAttempts"></a> MaxAttempts

The maximum number of attempts specific to this job. If
[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), `TraconSchedulingOptions.MaxAttempts` applies.

```csharp
public int? MaxAttempts { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)?

#### Remarks

Webhook delivery uses a ladder different from the global
setting; this field prevents a single global number from being forced
onto every kind of job.

### <a id="Tracon_JobRecord_MaxDuration"></a> MaxDuration

The longest time one attempt of this job may run. If [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null),
`TraconSchedulingOptions.MaxDurationByHandlerKey` applies to the job's
handler key, and a key the map does not list has no limit.

```csharp
public TimeSpan? MaxDuration { get; init; }
```

#### Property Value

 [TimeSpan](https://learn.microsoft.com/dotnet/api/system.timespan)?

#### Remarks

When the time is up, the worker cancels the token it gave the handler. A
handler that stops then fails the attempt with
[JobErrorCodes.MaxDurationExceeded](/api/tracon.joberrorcodes/#Tracon_JobErrorCodes_MaxDurationExceeded); the job is leased again while
attempts are left, and the next attempt gets the full time again. A handler
that ignores its token is waited for, and keeps its worker slot until it
returns. One that returns normally after the time is up completes the job.

Kept in the store beside [JobRecord.MaxAttempts](/api/tracon.jobrecord/#Tracon_JobRecord_MaxAttempts). A store that does not keep
it loses it: the job then runs under the map's value, or without a limit. A
stored value a timer cannot arm (outside 1 ms to about 49.7 days) is logged and
skipped the same way.

### <a id="Tracon_JobRecord_Payload"></a> Payload

The input set or parameters.

```csharp
public JsonElement Payload { get; init; }
```

#### Property Value

 [JsonElement](https://learn.microsoft.com/dotnet/api/system.text.json.jsonelement)

#### Remarks

An unset payload is stored as the empty JSON array, never as
`JsonValueKind.Undefined` or JSON `null`: an undefined
value cannot be written as JSON, and SQL Server rejects a `null`
literal in a JSON column. Every reader treats the empty array as "no payload".

### <a id="Tracon_JobRecord_ScheduleId"></a> ScheduleId

The identifier of the schedule that produced this job.
[null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for manually created (one-off) jobs.

```csharp
public Guid? ScheduleId { get; init; }
```

#### Property Value

 [Guid](https://learn.microsoft.com/dotnet/api/system.guid)?

### <a id="Tracon_JobRecord_ScheduledFor"></a> ScheduledFor

The earliest time the job is eligible to run (UTC).

```csharp
public required DateTimeOffset ScheduledFor { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)

### <a id="Tracon_JobRecord_StartedAt"></a> StartedAt

The time the first lease happened (UTC).

```csharp
public DateTimeOffset? StartedAt { get; init; }
```

#### Property Value

 [DateTimeOffset](https://learn.microsoft.com/dotnet/api/system.datetimeoffset)?

### <a id="Tracon_JobRecord_Status"></a> Status

The job's current status.

```csharp
public required JobStatus Status { get; init; }
```

#### Property Value

 [JobStatus](/api/tracon.jobstatus/)

### <a id="Tracon_JobRecord_TargetName"></a> TargetName

The agent or workflow name to run.

```csharp
public required string TargetName { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobRecord_TenantId"></a> TenantId

The tenant the job belongs to.

```csharp
public required string TenantId { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_JobRecord_TotalItems"></a> TotalItems

The total number of items.

```csharp
public int TotalItems { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

## Methods

### <a id="Tracon_JobRecord_Equals_System_Object_"></a> Equals\(object?\)

```csharp
public override bool Equals(object? obj)
```

#### Parameters

`obj` [object](https://learn.microsoft.com/dotnet/api/system.object)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_JobRecord_Equals_Tracon_JobRecord_"></a> Equals\(JobRecord?\)

```csharp
public bool Equals(JobRecord? other)
```

#### Parameters

`other` [JobRecord](/api/tracon.jobrecord/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_JobRecord_GetHashCode"></a> GetHashCode\(\)

```csharp
public override int GetHashCode()
```

#### Returns

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_JobRecord_ToString"></a> ToString\(\)

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Operators

### <a id="Tracon_JobRecord_op_Equality_Tracon_JobRecord_Tracon_JobRecord_"></a> operator ==\(JobRecord?, JobRecord?\)

```csharp
public static bool operator ==(JobRecord? left, JobRecord? right)
```

#### Parameters

`left` [JobRecord](/api/tracon.jobrecord/)?

`right` [JobRecord](/api/tracon.jobrecord/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="Tracon_JobRecord_op_Inequality_Tracon_JobRecord_Tracon_JobRecord_"></a> operator \!=\(JobRecord?, JobRecord?\)

```csharp
public static bool operator !=(JobRecord? left, JobRecord? right)
```

#### Parameters

`left` [JobRecord](/api/tracon.jobrecord/)?

`right` [JobRecord](/api/tracon.jobrecord/)?

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)
