package async_smtp

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Parameters

module R : Resource_intf

Signature

module Status : Status_intf with module Key := R.Key
type t
val init : config:Config.t -> t
val status : t -> Status.t
val config : t -> Config.t
val with_ : ?open_timeout:Core.Time.Span.t -> ?give_up:unit Async.Deferred.t -> t -> R.Args.t -> f:(R.t -> 'a Async.Deferred.t) -> 'a Async.Deferred.Or_error.t

with_ t args ~f calls f resource where resource is either:

1) An existing cached resource that was opened with args' such that R.Args.Key.equal (R.Args.key args) (R.Args.key args') = true 2) A newly opened resource created by R.open_ args, respecting the limits of t.config

Returns an error if:

  • the cache is closed
  • R.open_ returned an error
  • no resource is obtained before give_up is determined

If f raises, the exception is not caught, but the resource will be closed and the Cache will remain in a working state (no resources are lost).

val with_' : ?open_timeout:Core.Time.Span.t -> ?give_up:unit Async.Deferred.t -> t -> R.Args.t -> f:(R.t -> 'a Async.Deferred.t) -> [ `Ok of 'a | `Gave_up_waiting_for_resource | `Error_opening_resource of Core.Error.t | `Cache_is_closed ] Async.Deferred.t

Like with_ but classify the different errors

val with_any : ?open_timeout:Core.Time.Span.t -> ?give_up:unit Async.Deferred.t -> t -> R.Args.t list -> f:(R.t -> 'a Async.Deferred.t) -> (R.Args.t * 'a) Async.Deferred.Or_error.t

Like with_ and with_' except f is run on the first matching available resource (or the first resource that has availability to be opened). Preference is given towards those earlier in args_list when possible

val with_any' : ?open_timeout:Core.Time.Span.t -> ?give_up:unit Async.Deferred.t -> t -> R.Args.t list -> f:(R.t -> 'a Async.Deferred.t) -> [ `Ok of R.Args.t * 'a | `Error_opening_resource of R.Args.t * Core.Error.t | `Gave_up_waiting_for_resource | `Cache_is_closed ] Async.Deferred.t
val with_any_loop : ?open_timeout:Core.Time.Span.t -> ?give_up:unit Async.Deferred.t -> t -> R.Args.t list -> f:(R.t -> 'a Async.Deferred.t) -> [ `Ok of R.Args.t * 'a | `Error_opening_all_resources of (R.Args.t * Core.Error.t) list | `Gave_up_waiting_for_resource | `Cache_is_closed ] Async.Deferred.t

Tries with_any' in a loop (removing args that have open errors) until receiving an `Ok, or until it has failed to open all resources in args_list.

val close_started : t -> bool
val close_finished : t -> unit Async.Deferred.t
val close_and_flush : t -> unit Async.Deferred.t

Close all currently open resources and prevent the creation of new ones. All subsequent calls to with_ and immediate fail with `Cache_is_closed. Any jobs that are waiting for a connection will return with `Cache_is_closed. The returned Deferred.t is determined when all jobs have finished running and all resources have been closed.

OCaml

Innovation. Community. Security.