1- use log:: debug;
2- use tokio:: sync:: mpsc;
3- use tokio_stream:: wrappers:: ReceiverStream ;
4- use tonic:: { Request , Response , Status } ;
5-
61use proto:: scheduler:: {
72 instance_service_server:: InstanceService , Instance , InstanceIdentifier , InstanceStatus ,
83} ;
4+ use tokio:: sync:: mpsc;
5+ use tokio_stream:: wrappers:: ReceiverStream ;
6+ use tonic:: { Request , Response } ;
97
108use crate :: { manager:: Manager , Event } ;
119
@@ -25,8 +23,8 @@ impl InstanceService for InstanceListener {
2523 async fn create (
2624 & self ,
2725 request : Request < Instance > ,
28- ) -> Result < Response < Self :: CreateStream > , Status > {
29- debug ! ( "received request: {:?}" , request) ;
26+ ) -> Result < Response < Self :: CreateStream > , tonic :: Status > {
27+ log :: debug!( "received gRPC request: {:?}" , request) ;
3028 let ( tx, rx) = Manager :: create_mpsc_channel ( ) ;
3129
3230 match self
@@ -38,33 +36,22 @@ impl InstanceService for InstanceListener {
3836 return Ok ( Response :: new ( ReceiverStream :: new ( rx) ) ) ;
3937 }
4038 Err ( _) => {
41- return Err ( Status :: internal ( "could not send event to manager" ) ) ;
39+ return Err ( tonic :: Status :: internal ( "could not send event to manager" ) ) ;
4240 }
4341 }
4442 }
4543
46- type CreateStream = ReceiverStream < Result < InstanceStatus , Status > > ;
44+ type CreateStream = ReceiverStream < Result < InstanceStatus , tonic :: Status > > ;
4745
48- async fn start ( & self , request : Request < InstanceIdentifier > ) -> Result < Response < ( ) > , Status > {
49- debug ! ( "received request: {:?}" , request) ;
50- let ( tx, rx) = Manager :: create_oneshot_channel ( ) ;
51-
52- match self
53- . sender
54- . send ( Event :: InstanceStart ( request. into_inner ( ) . id , tx) )
55- . await
56- {
57- Ok ( _) => {
58- return rx. await . unwrap ( ) ;
59- }
60- Err ( _) => {
61- return Err ( Status :: internal ( "could not send event to manager" ) ) ;
62- }
63- }
46+ async fn start ( & self , _: Request < InstanceIdentifier > ) -> Result < Response < ( ) > , tonic:: Status > {
47+ Err ( tonic:: Status :: unimplemented ( "not implemented" ) )
6448 }
6549
66- async fn stop ( & self , request : Request < InstanceIdentifier > ) -> Result < Response < ( ) > , Status > {
67- debug ! ( "received request: {:?}" , request) ;
50+ async fn stop (
51+ & self ,
52+ request : Request < InstanceIdentifier > ,
53+ ) -> Result < Response < ( ) > , tonic:: Status > {
54+ log:: debug!( "received gRPC request: {:?}" , request) ;
6855 let ( tx, rx) = Manager :: create_oneshot_channel ( ) ;
6956
7057 match self
@@ -76,13 +63,16 @@ impl InstanceService for InstanceListener {
7663 return rx. await . unwrap ( ) ;
7764 }
7865 Err ( _) => {
79- return Err ( Status :: internal ( "could not send event to manager" ) ) ;
66+ return Err ( tonic :: Status :: internal ( "could not send event to manager" ) ) ;
8067 }
8168 }
8269 }
8370
84- async fn destroy ( & self , request : Request < InstanceIdentifier > ) -> Result < Response < ( ) > , Status > {
85- debug ! ( "received request: {:?}" , request) ;
71+ async fn destroy (
72+ & self ,
73+ request : Request < InstanceIdentifier > ,
74+ ) -> Result < Response < ( ) > , tonic:: Status > {
75+ log:: debug!( "received gRPC request: {:?}" , request) ;
8676 let ( tx, rx) = Manager :: create_oneshot_channel ( ) ;
8777
8878 match self
@@ -94,7 +84,7 @@ impl InstanceService for InstanceListener {
9484 return rx. await . unwrap ( ) ;
9585 }
9686 Err ( _) => {
97- return Err ( Status :: internal ( "could not send event to manager" ) ) ;
87+ return Err ( tonic :: Status :: internal ( "could not send event to manager" ) ) ;
9888 }
9989 }
10090 }
0 commit comments