@@ -5,7 +5,7 @@ export StaticConfig, ClientOptions, Config, AzureConfig, AWSConfig, SnowflakeCon
55export status_code, is_connection, is_timeout, is_early_eof, is_unknown, is_parse_url
66export get_object_stream, ReadStream, finish!
77export put_object_stream, WriteStream, cancel!, shutdown!
8- export current_metrics
8+ export current_metrics, invalidate_config
99export max_entries_per_chunk, ListEntry, list_objects, list_objects_stream, next_chunk!
1010
1111using Base. Libc. Libdl: dlext
@@ -1953,6 +1953,57 @@ function current_stage_info(conf::AbstractConfig)
19531953 end
19541954end
19551955
1956+ """
1957+ invalidate_config(conf::Option{AbstractConfig}) -> Bool
1958+
1959+ Invalidates the specified config (or all if no config is provided) in the Rust
1960+ config cache. This is useful to mitigate test interference.
1961+
1962+ # Arguments
1963+ - `conf::AbstractConfig`: (Optional) The config to be invalidated.
1964+ """
1965+ function invalidate_config (conf:: Option{AbstractConfig} = nothing )
1966+ response = Response ()
1967+ ct = current_task ()
1968+ event = Base. Event ()
1969+ handle = pointer_from_objref (event)
1970+ while true
1971+ preserve_task (ct)
1972+ result = GC. @preserve conf response event try
1973+ result = if ! isnothing (conf)
1974+ config = into_config (conf)
1975+ @ccall rust_lib. invalidate_config (
1976+ config:: Ref{Config} ,
1977+ response:: Ref{Response} ,
1978+ handle:: Ptr{Cvoid}
1979+ ):: Cint
1980+ else
1981+ @ccall rust_lib. invalidate_config (
1982+ C_NULL :: Ptr{Cvoid} ,
1983+ response:: Ref{Response} ,
1984+ handle:: Ptr{Cvoid}
1985+ ):: Cint
1986+ end
1987+
1988+ wait_or_cancel (event, response)
1989+
1990+ result
1991+ finally
1992+ unpreserve_task (ct)
1993+ end
1994+
1995+ if result == 2
1996+ # backoff
1997+ sleep (0.01 )
1998+ continue
1999+ end
2000+
2001+ @throw_on_error (response, " invalidate_config" , PutException)
2002+
2003+ return true
2004+ end
2005+ end
2006+
19562007struct Metrics
19572008 live_bytes:: Int64
19582009end
0 commit comments