GitHubTaskStorage

Struct GitHubTaskStorage 

Source
pub struct GitHubTaskStorage { /* private fields */ }
Expand description

GitHub Issues task storage implementation

Implementations§

Source§

impl GitHubTaskStorage

Source

pub fn new( token: String, repo_owner: String, repo_name: String, ) -> Result<Self, StorageError>

Create a new GitHub task storage

§Arguments
  • token - GitHub personal access token
  • repo_owner - Repository owner (org or user)
  • repo_name - Repository name

Trait Implementations§

Source§

impl TaskStorage for GitHubTaskStorage

Source§

fn save_task<'life0, 'async_trait>( &'life0 self, task: A2ATask, ) -> Pin<Box<dyn Future<Output = Result<u64, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Save a new task by creating a GitHub Issue

Creates a GitHub Issue with:

  • Title and description from task
  • Status label (e.g., a2a:pending)
  • Task type label (e.g., a2a:codegen)
§Arguments
  • task - The task to save
§Returns

GitHub Issue number (task ID)

Source§

fn get_task<'life0, 'async_trait>( &'life0 self, id: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<A2ATask>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a task by ID (GitHub Issue number)

§Arguments
  • id - GitHub Issue number
§Returns
  • Some(task) if found
  • None if not found (404)
  • Err for other errors
Source§

fn list_tasks<'life0, 'async_trait>( &'life0 self, filter: TaskFilter, ) -> Pin<Box<dyn Future<Output = Result<Vec<A2ATask>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List tasks with optional filtering

Uses GitHub API label filtering for status, combined with in-memory filtering for other criteria.

§Arguments
  • filter - Filter criteria (status, context_id, agent, updated_after, limit)
§Returns

List of tasks matching the filter

§Performance
  • Status filtering: API-level (reduces network transfer)
  • Other filters: In-memory (applied after fetch)
Source§

fn list_tasks_paginated<'life0, 'async_trait>( &'life0 self, filter: TaskFilter, ) -> Pin<Box<dyn Future<Output = Result<PaginatedResult<A2ATask>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List tasks with cursor-based pagination

Implements cursor-based pagination for efficient navigation through large task lists. Cursors encode the (id, updated_at) of the last item, ensuring stable pagination.

§Arguments
  • filter - Filter criteria including optional cursor
§Returns

PaginatedResult with items, next_cursor, previous_cursor, and has_more flag

§Pagination Strategy
  • Forward: Fetch limit+1 items after cursor to determine if has_more
  • Backward: Fetch limit+1 items before cursor
  • First page: No cursor provided, start from beginning
§Examples
use miyabi_a2a::{GitHubTaskStorage, TaskStorage, TaskFilter};

let storage = GitHubTaskStorage::new("token".into(), "owner".into(), "repo".into())?;

// First page (50 items)
let filter = TaskFilter { limit: Some(50), ..Default::default() };
let page1 = storage.list_tasks_paginated(filter).await?;

// Navigate to next page
if let Some(cursor) = page1.next_cursor {
    let filter = TaskFilter { cursor: Some(cursor), limit: Some(50), ..Default::default() };
    let page2 = storage.list_tasks_paginated(filter).await?;
}
Source§

fn update_task<'life0, 'async_trait>( &'life0 self, id: u64, update: TaskUpdate, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update an existing task

Updates task fields via GitHub Issue API:

  • Description: Updates Issue body
  • Status: Updates labels (removes old status label, adds new one)

Status update process:

  1. Fetch current Issue to get existing labels
  2. Filter out old status labels (a2a:pending, a2a:in-progress, etc.)
  3. Add new status label
  4. Update Issue with new label set
§Arguments
  • id - GitHub Issue number
  • update - Fields to update
§Returns

Ok(()) on success

Source§

fn delete_task<'life0, 'async_trait>( &'life0 self, id: u64, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete a task (closes GitHub Issue)

GitHub Issues cannot be permanently deleted, so this method closes the Issue instead. Closed Issues remain in the repository for audit trail purposes.

§Arguments
  • id - GitHub Issue number
§Returns

Ok(()) on success

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more