pub mod async_runtime;
pub mod error;
pub mod object_ref;
pub mod runtime;
pub mod serialize;
pub use rayrust_sys as sys;
pub use ctor;
pub use error::RayError;
pub use object_ref::ObjectRef;
pub use runtime::{
get_namespace, get_actor, cancel, get_many,
init, init_with_config, is_initialized, put, put_async, put_xlang, get, get_async, wait,
was_current_actor_restarted, shutdown, ActorHandle, RayConfig,
};
pub use serialize::{deserialize, deserialize_value, deserialize_xlang, deserialize_xlang_value, serialize, serialize_xlang};
pub use async_runtime::block_on_async;
pub use rmpv;
pub use rayrust_macros::{actor, remote};
pub fn register_member_function(
func_name: &str,
callback: extern "C" fn(u64, *const rayrust_sys::RayBytes, usize) -> rayrust_sys::RayBytes,
) {
let name_c = rayrust_sys::to_cstring(func_name);
unsafe {
rayrust_sys::ray_register_member_function(name_c.as_ptr(), callback);
}
}
pub fn placement_group_create(name: &str, bundles_json: &str, strategy: i32) -> Result<Vec<u8>, RayError> {
crate::runtime::placement_group_create_inner(name, bundles_json, strategy)
}
pub fn placement_group_remove(group_id: &[u8]) {
crate::runtime::placement_group_remove_inner(group_id);
}
pub fn task_call(func_name: &str, args: &[&[u8]], is_ref: &[bool]) -> Result<ObjectRef<()>, RayError> {
crate::runtime::task_call_inner(func_name, args, is_ref)
}
pub fn task_call_with_resources(
func_name: &str,
args: &[&[u8]],
is_ref: &[bool],
resources: &[(&str, f64)],
) -> Result<ObjectRef<()>, RayError> {
crate::runtime::task_call_with_resources_inner(func_name, args, is_ref, resources)
}
pub async fn task_call_async(func_name: &str, args: Vec<Vec<u8>>, is_ref: Vec<bool>) -> Result<ObjectRef<()>, RayError> {
crate::runtime::task_call_inner_async(func_name.to_string(), args, is_ref).await
}
pub fn task_call_python(
module: &str,
function: &str,
args: &[&[u8]],
is_ref: &[bool],
) -> Result<ObjectRef<()>, RayError> {
let id = crate::runtime::task_call_python_inner(module, function, args, is_ref)?;
Ok(ObjectRef::from_id_xlang(id))
}
pub fn actor_create(func_name: &str, args: &[&[u8]], is_ref: &[bool]) -> Result<ActorHandle, RayError> {
crate::runtime::actor_create_inner(func_name, args, is_ref)
}
pub fn actor_create_with_resources(
func_name: &str,
args: &[&[u8]],
resources: &[(&str, f64)],
) -> Result<ActorHandle, RayError> {
crate::runtime::actor_create_with_resources_inner(func_name, args, resources)
}
pub fn actor_create_python(module: &str, class: &str, args: &[&[u8]]) -> Result<ActorHandle, RayError> {
crate::runtime::actor_create_python_inner(module, class, args)
}
pub fn actor_call(actor_id: &[u8], func_name: &str, args: &[&[u8]]) -> Result<ObjectRef<()>, RayError> {
crate::runtime::actor_call_inner(actor_id, func_name, args)
}
pub async fn actor_call_async(
actor_id: &[u8],
func_name: &str,
args: Vec<Vec<u8>>,
) -> Result<ObjectRef<()>, RayError> {
crate::runtime::actor_call_inner_async(actor_id.to_vec(), func_name.to_string(), args).await
}
pub fn actor_call_python(
actor_id: &[u8],
method_name: &str,
args: &[&[u8]],
is_ref: &[bool],
) -> Result<ObjectRef<()>, RayError> {
let id = crate::runtime::actor_call_python_inner(actor_id, method_name, args, is_ref)?;
Ok(ObjectRef::from_id_xlang(id))
}
pub fn actor_kill(actor_id: &[u8], no_restart: bool) {
crate::runtime::actor_kill_inner(actor_id, no_restart);
}
pub mod prelude {
pub use crate::error::RayError;
pub use crate::object_ref::ObjectRef;
pub use crate::runtime::{
ActorHandle, RayConfig, init, init_with_config,
put, put_async, put_xlang, get, get_async, wait, shutdown,
};
pub use crate::serialize::{
deserialize, deserialize_value, deserialize_xlang, deserialize_xlang_value,
serialize, serialize_xlang,
};
pub use crate::{
actor_call, actor_call_async, actor_create, actor_create_with_resources, actor_kill,
get_namespace, get_actor, cancel, get_many,
task_call, task_call_with_resources, task_call_async, was_current_actor_restarted,
task_call_python, actor_create_python, actor_call_python,
placement_group_create, placement_group_remove,
rmpv,
};
pub use rayrust_macros::{actor, remote};
}