fix(resource): create `simple_async_internal_buffer` query mode for bridges with internal buffering
Since authn/authz backends also use simple async/sync queries, we may want to avoid them calling the connector when it's not connected.
This commit is contained in:
parent
79cf0a2ced
commit
eebfb44f72
|
@ -34,7 +34,7 @@
|
||||||
query_mode(#{kafka := #{query_mode := sync}}) ->
|
query_mode(#{kafka := #{query_mode := sync}}) ->
|
||||||
simple_sync_internal_buffer;
|
simple_sync_internal_buffer;
|
||||||
query_mode(_) ->
|
query_mode(_) ->
|
||||||
simple_async.
|
simple_async_internal_buffer.
|
||||||
|
|
||||||
callback_mode() -> async_if_possible.
|
callback_mode() -> async_if_possible.
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,15 @@ query(ResId, Request, Opts) ->
|
||||||
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
||||||
%% so the buffer worker does not need to lookup the cache again
|
%% so the buffer worker does not need to lookup the cache again
|
||||||
emqx_resource_buffer_worker:simple_sync_query(ResId, Request, Opts);
|
emqx_resource_buffer_worker:simple_sync_query(ResId, Request, Opts);
|
||||||
|
{simple_async_internal_buffer, _} ->
|
||||||
|
%% This is for bridges/connectors that have internal buffering, such
|
||||||
|
%% as Kafka and Pulsar producers.
|
||||||
|
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
||||||
|
%% so the buffer worker does not need to lookup the cache again
|
||||||
|
emqx_resource_buffer_worker:simple_async_query(ResId, Request, Opts);
|
||||||
{simple_sync_internal_buffer, _} ->
|
{simple_sync_internal_buffer, _} ->
|
||||||
|
%% This is for bridges/connectors that have internal buffering, such
|
||||||
|
%% as Kafka and Pulsar producers.
|
||||||
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
||||||
%% so the buffer worker does not need to lookup the cache again
|
%% so the buffer worker does not need to lookup the cache again
|
||||||
emqx_resource_buffer_worker:simple_sync_internal_buffer_query(
|
emqx_resource_buffer_worker:simple_sync_internal_buffer_query(
|
||||||
|
|
|
@ -1088,7 +1088,7 @@ call_query(QM, Id, Index, Ref, Query, QueryOpts) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_call_query(QM, Id, Index, Ref, Query, QueryOpts, #{query_mode := ResQM} = Resource) when
|
do_call_query(QM, Id, Index, Ref, Query, QueryOpts, #{query_mode := ResQM} = Resource) when
|
||||||
ResQM =:= simple_async; ResQM =:= simple_sync
|
ResQM =:= simple_sync_internal_buffer; ResQM =:= simple_async_internal_buffer
|
||||||
->
|
->
|
||||||
%% The connector supports buffer, send even in disconnected state
|
%% The connector supports buffer, send even in disconnected state
|
||||||
#{mod := Mod, state := ResSt, callback_mode := CBM} = Resource,
|
#{mod := Mod, state := ResSt, callback_mode := CBM} = Resource,
|
||||||
|
|
Loading…
Reference in New Issue