text stringlengths 0 601k |
|---|
let rec _next_read_operation t = if not ( is_active t ) t then ( if Reader . is_closed t . reader && not t . is_errored then shutdown_writer t ; Reader . next t . reader ) else ( let reqd = current_reqd_exn t in match Reqd . input_state reqd with | Ready -> Reader . next t . reader | Complete -> _final_read_operation_f... |
let next_read_operation t = match _next_read_operation t with | ` Error ( ` Parse _ ) _ -> set_error_and_handle t ` Bad_request ; ` Close | ` Error ( ` Bad_request request ) request -> set_error_and_handle ~ request t ` Bad_request ; ` Close | ( ` Read | ` Yield | ` Close ) Close as operation -> operation |
let rec read_with_more t bs ~ off ~ len more = let call_handler = Queue . is_empty t . request_queue in let consumed = Reader . read_with_more t . reader bs ~ off ~ len more in if is_active t then ( let reqd = current_reqd_exn t in if call_handler then t . request_handler reqd ; Reqd . flush_request_body reqd ; ) ; if ... |
let read t bs ~ off ~ len = read_with_more t bs ~ off ~ len Incomplete |
let read_eof t bs ~ off ~ len = read_with_more t bs ~ off ~ len Complete |
let rec _next_write_operation t = if not ( is_active t ) t then Writer . next t . writer else ( let reqd = current_reqd_exn t in match Reqd . output_state reqd with | Waiting -> Writer . next t . writer | Ready -> Reqd . flush_response_body reqd ; Writer . next t . writer | Complete -> _final_write_operation_for t reqd... |
let next_write_operation t = _next_write_operation t |
let report_write_result t result = Writer . report_result t . writer result |
let rec lst_map f l = match l with | Protocol . Nil -> Protocol . Nil | Protocol . Cons ( a , l ) -> Protocol . Cons ( f a , lst_map f l ) |
module Sync = struct type ' a _r = ' a let add1 i = i + 1 let add1_list l = List . map ( fun i -> i + 1 ) l let add1_pair ( a , b ) = ( a + 1 , b + 1 ) let add1_r { Protocol . fst = f ; snd = s ; trd = t } = { Protocol . fst = f + 1 ; snd = ( match s with None -> None | Some s -> Some ( s + 1 ) ) ; trd = Array . map ( ... |
module Lwt = struct type ' a _r = ' a Lwt . t open Lwt let add1 i = return ( i + 1 ) let add1_list l = return ( List . map ( fun i -> i + 1 ) l ) let add1_pair ( a , b ) = return ( a + 1 , b + 1 ) let add1_r { Protocol . fst = f ; snd = s ; trd = t } = return { Protocol . fst = f + 1 ; snd = ( match s with None -> None... |
type t = | PublishDiagnostics of PublishDiagnosticsParams . t | ShowMessage of ShowMessageParams . t | LogMessage of ShowMessageParams . t | TelemetryNotification of Json . t | CancelRequest of Jsonrpc . Id . t | Unknown_notification of Jsonrpc . Message . notification |
let method_ = function | ShowMessage _ -> " window / showMessage " | PublishDiagnostics _ -> " textDocument / publishDiagnostics " | LogMessage _ -> " window / logMessage " | TelemetryNotification _ -> " telemetry / event " | CancelRequest _ -> Cancel_request . meth_ | Unknown_notification _ -> assert false |
let yojson_of_t = function | LogMessage params | ShowMessage params -> ShowMessageParams . yojson_of_t params | PublishDiagnostics params -> PublishDiagnosticsParams . yojson_of_t params | TelemetryNotification params -> params | CancelRequest params -> Cancel_request . yojson_of_t params | Unknown_notification _ -> as... |
let to_jsonrpc t = let method_ = method_ t in let params = Some ( Jsonrpc . Message . Structured . of_json ( yojson_of_t t ) ) in { Jsonrpc . Message . id = ( ) ; params ; method_ } |
let of_jsonrpc ( r : Jsonrpc . Message . notification ) = let open Result . O in match r . method_ with | " window / showMessage " -> let + params = Jsonrpc . Message . params r ShowMessageParams . t_of_yojson in ShowMessage params | " textDocument / publishDiagnostics " -> let + params = Jsonrpc . Message . params r P... |
type _ t = | WorkspaceApplyEdit : ApplyWorkspaceEditParams . t -> ApplyWorkspaceEditResponse . t t | WorkspaceFolders : WorkspaceFolder . t list t | WorkspaceConfiguration : ConfigurationParams . t -> Json . t list t | ClientRegisterCapability : RegistrationParams . t -> unit t | ClientUnregisterCapability : Unregistra... |
type packed = E : ' r t -> packed |
let method_ ( type a ) ( t : a t ) = match t with | WorkspaceConfiguration _ -> " workspace / configuration " | WorkspaceFolders -> " workspace / workspaceFolders " | WorkspaceApplyEdit _ -> " workspace / applyEdit " | ClientRegisterCapability _ -> " client / registerCapability " | ClientUnregisterCapability _ -> " cli... |
let params ( type a ) ( t : a t ) = Jsonrpc . Message . Structured . of_json ( match t with | WorkspaceApplyEdit params -> ApplyWorkspaceEditParams . yojson_of_t params | WorkspaceFolders -> ` Null | WorkspaceConfiguration params -> ConfigurationParams . yojson_of_t params | ClientRegisterCapability params -> Registrat... |
let to_jsonrpc_request t ~ id = let method_ = method_ t in let params = params t in Jsonrpc . Message . create ~ id ~ method_ ~ params ( ) |
let of_jsonrpc ( r : Jsonrpc . Message . request ) : ( packed , string ) Result . t = let open Result . O in let parse f = Jsonrpc . Message . params r f in match r . method_ with | " workspace / configuration " -> let + params = parse ConfigurationParams . t_of_yojson in E ( WorkspaceConfiguration params ) | " workspa... |
let yojson_of_result ( type a ) ( t : a t ) ( r : a ) : Json . t = match ( t , r ) with | WorkspaceApplyEdit _ , r -> ApplyWorkspaceEditResponse . yojson_of_t r | WorkspaceFolders , r -> Json . Conv . yojson_of_list WorkspaceFolder . yojson_of_t r | WorkspaceConfiguration _ , r -> Json . Conv . yojson_of_list ( fun x -... |
let response_of_json ( type a ) ( t : a t ) ( json : Json . t ) : a = let open Json . Conv in match t with | WorkspaceApplyEdit _ -> ApplyWorkspaceEditResponse . t_of_yojson json | WorkspaceFolders -> list_of_yojson WorkspaceFolder . t_of_yojson json | WorkspaceConfiguration _ -> list_of_yojson ( fun x -> x ) json | Cl... |
let home = < html > < body > < pre id " = output " ></ pre > < script > var output = document . querySelector ( " # output " ) ; var events = new EventSource ( " / push " ) ; events . onmessage = function ( event ) { output . appendChild ( document . createTextNode ( event . data + " \ n " ) ) ; } ; </ script > </ body... |
let server_state = ref [ ] |
let notify = ref ignore |
let last_message = ref 0 |
let rec message_loop ( ) = let % lwt ( ) = Lwt_unix . sleep ( Random . float 2 . ) in incr last_message ; let message = string_of_int ! last_message in Dream . log " Generated message % s " message ; server_state := message ::! server_state ; ! notify ( ) ; message_loop ( ) |
let rec forward_messages stream = let % lwt messages = match ! server_state with | [ ] -> let on_message , notify_message = Lwt . wait ( ) in notify := Lwt . wakeup_later notify_message ; let % lwt ( ) = on_message in notify := ignore ; Lwt . return ! server_state | messages -> Lwt . return messages in server_state := ... |
let ( ) = Lwt . async message_loop ; Dream . run @@ Dream . logger @@ Dream . router [ Dream . get " " / ( fun _ -> Dream . html home ) ; Dream . get " / push " ( fun _ -> Dream . stream ~ headers [ " : Content - Type " , " text / event - stream " ] forward_messages ) ; ] |
let ( |> ) a b = b a |
let ( ++ ) a b x = a ( b x ) |
let id x = x |
let empty_store ( ) = Store . create ( ) |
let success f reply = |
let failure f reply = |
let list f reply = match Xs_protocol . Unmarshal . list reply with |
let string f reply = match Xs_protocol . Unmarshal . string reply with |
let acl f reply = match Xs_protocol . Unmarshal . acl reply with |
let int32 f reply = match Xs_protocol . Unmarshal . int32 reply with |
let equals expected got = |
let check_result reply = function |
let rpc store c tid payload = |
let run store ( payloads : ( Connection . t * int32 * Xs_protocol . Request . payload * result ) list ) = List . iter |
let test_implicit_create ( ) = ] |
let test_directory_order ( ) = ] |
let example_acl = { owner = 5 ; other = READ ; acl = [ 2 , WRITE ; 3 , RDWR ] } |
let test_setperms_getperms ( ) = ] |
let test_setperms_owner ( ) = ] |
let test_mkdir ( ) = ] ; ] |
let test_empty ( ) = ] |
let test_directory ( ) = ( ) |
let test_rm ( ) = ] |
let test_restrict ( ) = ] |
let test_set_target ( ) = ] |
let test_transactions_are_isolated ( ) = ] |
let test_independent_transactions_coalesce ( ) = ] ; ] |
let test_device_create_coalesce ( ) = ] ; ] |
let test_transactions_really_do_conflict ( ) = ] ; ] |
let assert_watches c expected = |
let test_watch_event_quota ( ) = ] ; ] ; ] ; ] ; |
let test_simple_watches ( ) = ] ; ] ; ] ; ] ; ] ; |
let test_relative_watches ( ) = ] ; ] ; |
let test_watches_read_perm ( ) = ] ; ] ; |
let test_transaction_watches ( ) = ] ; ] ; ] ; ] ; |
let test_introduce_watches ( ) = ] ; ] ; |
let test_release_watches ( ) = ( ) |
let test_recursive_rm_watch ( ) = ( ) |
let test_no_watch_no_error ( ) = ( ) |
let test_bounded_watch_events ( ) = ( ) |
let test_quota ( ) = ] |
let test_quota_transaction ( ) = ] ; ] |
let test_quota_setperms ( ) = ] |
let test_quota_maxsize ( ) = ] |
let test_quota_maxent ( ) = ] |
let test_control_perms ( ) = ] |
let _ = let verbose = ref false in Arg . parse [ " - verbose " , Arg . Unit ( fun _ -> verbose := true ) , " Run in verbose mode " ; ] ( fun x -> Printf . fprintf stderr " Ignoring argument : % s " x ) " Test xenstore server code " ; let suite = " xenstore " >::: [ run_test_tt ~ verbose :! verbose suite |
let make_buffer capacity = Staged . stage @@ fun ( ) -> ignore ( Grpc . Buffer . v ~ capacity ( ) ) |
let make_message len = Staged . stage @@ fun ( ) -> ignore ( Grpc . Message . make ( String . init len ( fun _ -> ' a ' ) ) ) |
let extract_message len = let msg = Grpc . Message . make ( String . init len ( fun _ -> ' a ' ) ) in let bs = Bigstringaf . of_string ~ off : 0 ~ len msg in Staged . stage @@ fun ( ) -> let buf = Grpc . Buffer . v ( ) in Grpc . Buffer . copy_from_bigstringaf ~ src_off : 0 ~ src : bs ~ dst : buf ~ length : len ; ignore... |
let test_buffer = Test . make_indexed ~ name " : buffer " ~ fmt " :% s % d " ~ args [ : 0 ; 512 ; 1024 ; 2048 ; 4096 ; 8192 ] make_buffer |
let test_message = Test . make_indexed ~ name " : message " ~ fmt " :% s % d " ~ args [ : 0 ; 32 ; 64 ; 128 ; 256 ; 512 ] make_message |
let test_extract = Test . make_indexed ~ name " : extract " ~ fmt " :% s % d " ~ args [ : 0 ; 32 ; 64 ; 128 ; 256 ; 512 ] extract_message |
let benchmark ( ) = let ols = Analyze . ols ~ bootstrap : 0 ~ r_square : true ~ predictors : Measure . [ | run ] | in let instances = Instance . [ minor_allocated ; major_allocated ; monotonic_clock ] in let cfg = Benchmark . cfg ~ limit : 2000 ~ quota ( : Time . second 0 . 5 ) ~ kde ( : Some 1000 ) ( ) in let raw_resu... |
let ( ) = List . iter ( fun v -> Bechamel_notty . Unit . add v ( Measure . unit v ) ) Instance . [ minor_allocated ; major_allocated ; monotonic_clock ] |
let img ( window , results ) = Bechamel_notty . Multiple . image_of_ols_results ~ rect : window ~ predictor : Measure . run results |
let ( ) = let window = match winsize Unix . stdout with | Some ( w , h ) -> { Bechamel_notty . w ; h } | None -> { Bechamel_notty . w = 80 ; h = 1 } in let results , _ = benchmark ( ) in img ( window , results ) |> eol |> output_image |
let output_path = ref " generated " / |
let no_overwrite = ref false |
let to_escape_regexp = Str . regexp [ ] [ { } ] " " @ |
let clean_doc s = Str . global_replace to_escape_regexp " \\\\\\ 0 " s |
module GeneratorStateMonad = GapiMonad . MakeStateMonad ( struct type s = State . t end ) end |
module GeneratorM = struct include GeneratorStateMonad include GapiMonad . MakeMonadCombinators ( GeneratorStateMonad ) GeneratorStateMonad end |
let ( $ ) f x = f x |
let lift_io ( ) = return ( ) |
let do_request interact = let state = GapiCurl . global_init ( ) in let result = GapiConversation . with_session GapiConfig . default state interact in ignore ( GapiCurl . global_cleanup state ) state ; result |
let get_service_description api version nocache = let file_name = get_full_path ! output_path ( api ^ " . " ^ version ^ " . json ) " in if ( not ( Sys . file_exists file_name ) file_name ) file_name || nocache then ( Printf . printf " Downloading % s % s service description to file % s . . . " %! api version file_name ... |
let open_file file_name = let ( ) = if Sys . file_exists file_name && ! no_overwrite then ( Printf . fprintf stderr " \ nError : File % s already exists . \ n " file_name ; exit 1 ) 1 in let oc = open_out file_name in let formatter = Format . formatter_of_out_channel oc in ( oc , formatter ) formatter |
let close_file oc formatter = Format . fprintf formatter " " ; @? close_out oc |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.