Skip to content

Commit 8fe7640

Browse files
committed
Export invalidate_config function
1 parent ff735ce commit 8fe7640

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ReTestItems = "1"
2020
Sockets = "1"
2121
Test = "1"
2222
julia = "1.8"
23-
object_store_ffi_jll = "0.9.0"
23+
object_store_ffi_jll = "0.9.1"
2424

2525
[extras]
2626
CloudBase = "85eb1798-d7c4-4918-bb13-c944d38e27ed"

src/RustyObjectStore.jl

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export StaticConfig, ClientOptions, Config, AzureConfig, AWSConfig, SnowflakeCon
55
export status_code, is_connection, is_timeout, is_early_eof, is_unknown, is_parse_url
66
export get_object_stream, ReadStream, finish!
77
export put_object_stream, WriteStream, cancel!, shutdown!
8-
export current_metrics
8+
export current_metrics, invalidate_config
99
export max_entries_per_chunk, ListEntry, list_objects, list_objects_stream, next_chunk!
1010

1111
using Base.Libc.Libdl: dlext
@@ -1953,6 +1953,57 @@ function current_stage_info(conf::AbstractConfig)
19531953
end
19541954
end
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+
19562007
struct Metrics
19572008
live_bytes::Int64
19582009
end

0 commit comments

Comments
 (0)