Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions core/rust/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2015,3 +2015,127 @@ pub unsafe extern "C" fn hs_remove_search_attributes(
}
});
}

// TODO: [publish-crate]
/// # Safety
///
/// Haskell <-> Tokio FFI bridge invariants.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hs_start_batch_operation(
client: *mut ClientRef,
c_call: *const RpcCall,
mvar: *mut MVar,
cap: Capability,
error_slot: *mut *mut CRPCError,
result_slot: *mut *mut CArray<u8>,
) {
let client = unsafe { &mut *client };
let mut retry_client = client.retry_client.clone();
let call: TemporalCall = unsafe { (&*c_call).into() };

let callback: HsCallback<CArray<u8>, CRPCError> = HsCallback {
cap,
mvar,
result_slot,
error_slot,
};
client.runtime.future_result_into_hs(callback, async move {
match rpc_call!(retry_client, call, start_batch_operation) {
Ok(resp) => Ok(CArray::c_repr_of(resp).unwrap()),
Err(err) => Err(err),
}
});
}

// TODO: [publish-crate]
/// # Safety
///
/// Haskell <-> Tokio FFI bridge invariants.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hs_stop_batch_operation(
client: *mut ClientRef,
c_call: *const RpcCall,
mvar: *mut MVar,
cap: Capability,
error_slot: *mut *mut CRPCError,
result_slot: *mut *mut CArray<u8>,
) {
let client = unsafe { &mut *client };
let mut retry_client = client.retry_client.clone();
let call: TemporalCall = unsafe { (&*c_call).into() };

let callback: HsCallback<CArray<u8>, CRPCError> = HsCallback {
cap,
mvar,
result_slot,
error_slot,
};
client.runtime.future_result_into_hs(callback, async move {
match rpc_call!(retry_client, call, stop_batch_operation) {
Ok(resp) => Ok(CArray::c_repr_of(resp).unwrap()),
Err(err) => Err(err),
}
});
}

// TODO: [publish-crate]
/// # Safety
///
/// Haskell <-> Tokio FFI bridge invariants.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hs_describe_batch_operation(
client: *mut ClientRef,
c_call: *const RpcCall,
mvar: *mut MVar,
cap: Capability,
error_slot: *mut *mut CRPCError,
result_slot: *mut *mut CArray<u8>,
) {
let client = unsafe { &mut *client };
let mut retry_client = client.retry_client.clone();
let call: TemporalCall = unsafe { (&*c_call).into() };

let callback: HsCallback<CArray<u8>, CRPCError> = HsCallback {
cap,
mvar,
result_slot,
error_slot,
};
client.runtime.future_result_into_hs(callback, async move {
match rpc_call!(retry_client, call, describe_batch_operation) {
Ok(resp) => Ok(CArray::c_repr_of(resp).unwrap()),
Err(err) => Err(err),
}
});
}

// TODO: [publish-crate]
/// # Safety
///
/// Haskell <-> Tokio FFI bridge invariants.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hs_list_batch_operations(
client: *mut ClientRef,
c_call: *const RpcCall,
mvar: *mut MVar,
cap: Capability,
error_slot: *mut *mut CRPCError,
result_slot: *mut *mut CArray<u8>,
) {
let client = unsafe { &mut *client };
let mut retry_client = client.retry_client.clone();
let call: TemporalCall = unsafe { (&*c_call).into() };

let callback: HsCallback<CArray<u8>, CRPCError> = HsCallback {
cap,
mvar,
result_slot,
error_slot,
};
client.runtime.future_result_into_hs(callback, async move {
match rpc_call!(retry_client, call, list_batch_operations) {
Ok(resp) => Ok(CArray::c_repr_of(resp).unwrap()),
Err(err) => Err(err),
}
});
}
54 changes: 54 additions & 0 deletions core/src/Temporal/Core/Client/WorkflowService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ module Temporal.Core.Client.WorkflowService (
describeSchedule,
describeTaskQueue,
describeWorkflowExecution,
describeBatchOperation,
getClusterInfo,
getSearchAttributes,
getSystemInfo,
getWorkerBuildIdCompatibility,
getWorkflowExecutionHistory,
getWorkflowExecutionHistoryReverse,
listArchivedWorkflowExecutions,
listBatchOperations,
listClosedWorkflowExecutions,
listNamespaces,
listOpenWorkflowExecutions,
Expand Down Expand Up @@ -50,7 +52,9 @@ module Temporal.Core.Client.WorkflowService (
scanWorkflowExecutions,
signalWithStartWorkflowExecution,
signalWorkflowExecution,
startBatchOperation,
startWorkflowExecution,
stopBatchOperation,
terminateWorkflowExecution,
updateNamespace,
updateSchedule,
Expand Down Expand Up @@ -617,3 +621,53 @@ members are compatible with one another.
-}
updateWorkerBuildIdCompatibility :: Client -> UpdateWorkerBuildIdCompatibilityRequest -> IO (Either RpcError UpdateWorkerBuildIdCompatibilityResponse)
updateWorkerBuildIdCompatibility = call @WorkflowService @"updateWorkerBuildIdCompatibility" hs_update_worker_build_id_compatibility


foreign import ccall "hs_start_batch_operation" hs_start_batch_operation :: PrimRpcCall


{- |
StartBatchOperation starts a new batch operation that applies to multiple workflow executions.

Batch operations allow you to perform actions like terminate, cancel, signal, or delete on
multiple workflow executions that match a visibility query.
-}
startBatchOperation :: Client -> StartBatchOperationRequest -> IO (Either RpcError StartBatchOperationResponse)
startBatchOperation = call @WorkflowService @"startBatchOperation" hs_start_batch_operation


foreign import ccall "hs_stop_batch_operation" hs_stop_batch_operation :: PrimRpcCall


{- |
StopBatchOperation stops an ongoing batch operation.

This will prevent the batch operation from processing any additional workflow executions,
but will not undo operations that have already been performed.
-}
stopBatchOperation :: Client -> StopBatchOperationRequest -> IO (Either RpcError StopBatchOperationResponse)
stopBatchOperation = call @WorkflowService @"stopBatchOperation" hs_stop_batch_operation


foreign import ccall "hs_describe_batch_operation" hs_describe_batch_operation :: PrimRpcCall


{- |
DescribeBatchOperation returns information about a batch operation.

This includes the current state, progress statistics, and operation details.
-}
describeBatchOperation :: Client -> DescribeBatchOperationRequest -> IO (Either RpcError DescribeBatchOperationResponse)
describeBatchOperation = call @WorkflowService @"describeBatchOperation" hs_describe_batch_operation


foreign import ccall "hs_list_batch_operations" hs_list_batch_operations :: PrimRpcCall


{- |
ListBatchOperations lists all batch operations in a namespace.

Results can be filtered and paginated using the request parameters.
-}
listBatchOperations :: Client -> ListBatchOperationsRequest -> IO (Either RpcError ListBatchOperationsResponse)
listBatchOperations = call @WorkflowService @"listBatchOperations" hs_list_batch_operations
Loading