Module Cosmos_eio.Databases

module type Auth_key = Cosmos.Databases_intf.Auth_key
module Credential : sig ... end
module type Credentials = Cosmos.Databases_intf.Credentials
type 'a io = unit -> 'a

A deferred IO computation. Call with () to execute. This is the Eio equivalent of 'a Lwt.t; computations are deferred as thunks so that with_timeout can cancel them via Eio's fiber cancellation.

val with_env : sw:Eio.Switch.t -> < clock : _ Eio.Time.clock ; net : _ Eio.Net.t.. > -> (unit -> 'a) -> 'a

with_env ~sw env f sets up the Eio environment (clock, network, TLS client) required by Database operations. All database calls must happen inside f. Call this once inside Eio_main.run and Eio.Switch.run.

module Response_headers : sig ... end
type batch_validation_error = Cosmos.Databases_core.batch_validation_error =
  1. | Too_many_operations of int
  2. | Mixed_patch_operations
  3. | Empty_batch
type cosmos_error = Cosmos.Databases_core.Cosmos_error.t =
  1. | Timeout_error
  2. | Connection_error
  3. | Http_error of string
  4. | Azure_error of int * Response_headers.t
val string_of_cosmos_error : cosmos_error -> string

Human-readable description of a cosmos_error.

module type S = Database_intf.S

Database connects with master-key authentication.

module Database_as (C : Credentials) : S

Database_as connects with an arbitrary credential, e.g. a resource token minted through Permission. Master-key-only operations (list_databases, User, Permission, Offer) fail with Azure_error (401 | 403, _) under a resource token.

val credentials_of_token : endpoint:string -> string -> (module Credentials)

credentials_of_token ~endpoint token wraps a permission's _token as credentials suitable for Database_as.

val credentials_of_token_provider : endpoint:string -> (unit -> string) -> (module Credentials)

credentials_of_token_provider ~endpoint provider calls provider for every request, so callers can refresh expiring resource tokens.