Skip to content

GSB Service

Przemysław Rekucki edited this page Feb 7, 2020 · 2 revisions

Generating API

Proposition

#[gsb("/local/my-service")]
trait MyService {
   
   async fn create(&self, create : Create) -> Result<(), Error>;

   async fn update(&self, update : Update) -> Result<bool, Error>;

}

Generates

impl RpcMessage for Create {
   const ID :&str = "create";
   type Item = ();
   type Error = Error;
}

impl RpcMessage for Update {
   const ID :&str = "update";
   type Item = bool;
   type Error = Error;
}

pub struct MyService { 
... 
}

impl MyService {
  pub const ID = "/local/my-service";

  pub async fn create(&self, create : Create) -> Result<(), Error> {...}

  pub async fn update(&self, update : Update) -> Result<bool, Error> {...}

  pub fn new() -> Self;
}

Generating Implementation

#[gsb]
impl MyService for Service {
    
    async fn create(&self, create : Create) -> Result<(), Error> {...}

    fn update(&self, update : Update) -> ActorFuture<Self, bool, Error> { ... }
}
Clone this wiki locally