File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ [package ]
2+ name = " plugin"
3+ version = " 0.1.0"
4+ authors = [
" hasheddan <[email protected] >" ]
5+ edition = " 2018"
6+
7+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+ [dependencies ]
10+ k8s-deviceplugin = { path = " ../k8s-deviceplugin" }
11+ tonic = " 0.4"
12+ prost = " 0.7"
13+ tokio = { version = " 1.0" , features = [" macros" , " rt-multi-thread" ] }
14+ tower = { version = " 0.4" }
Original file line number Diff line number Diff line change 1+ use k8s_deviceplugin:: v1beta1:: registration_client:: RegistrationClient ;
2+ use k8s_deviceplugin:: v1beta1;
3+ use tokio:: net:: UnixStream ;
4+ use std:: convert:: TryFrom ;
5+ use tonic:: transport:: { Endpoint , Uri } ;
6+ use tower:: service_fn;
7+
8+ #[ tokio:: main]
9+ async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
10+ let channel = Endpoint :: try_from ( "http://[::]:50051" ) ?
11+ . connect_with_connector ( service_fn ( |_: Uri | {
12+ UnixStream :: connect ( v1beta1:: KUBELET_SOCKET )
13+ } ) )
14+ . await ?;
15+ let mut client = RegistrationClient :: new ( channel) ;
16+ let request = tonic:: Request :: new ( v1beta1:: RegisterRequest {
17+ endpoint : format ! ( "{}/fpgk8s.sock" , v1beta1:: KUBELET_SOCKET ) ,
18+ resource_name : "fpgk8s.io/fpga" . into ( ) ,
19+ version : v1beta1:: VERSION . into ( ) ,
20+ options : None ,
21+ } ) ;
22+
23+ let response = client. register ( request) . await ?;
24+
25+ println ! ( "RESPONSE={:?}" , response) ;
26+ Ok ( ( ) )
27+ }
You can’t perform that action at this time.
0 commit comments