|
200 | 200 | -export([new/2, new/3, name/1]). |
201 | 201 |
|
202 | 202 | %% For internal use only |
203 | | --export([check_compatibility_with_store/2, init/1, trigger/4, delete/1]). |
| 203 | +-export([check_compatibility_with_store/3, init/1, trigger/4, delete/1]). |
204 | 204 |
|
205 | 205 | -type name() :: atom(). |
206 | 206 | %% The name of a projection. |
@@ -510,33 +510,24 @@ to_ets_options(Key, Value, _Acc) -> |
510 | 510 | name(#khepri_projection{name = Name}) -> |
511 | 511 | Name. |
512 | 512 |
|
513 | | --spec check_compatibility_with_store(StoreId, Projection) -> Ret when |
| 513 | +-spec check_compatibility_with_store(StoreId, Projection, Timeout) -> Ret when |
514 | 514 | StoreId :: khepri:store_id(), |
515 | 515 | Projection :: khepri_projection:projection(), |
| 516 | + Timeout :: timeout(), |
516 | 517 | Ret :: ok | {error, any()}. |
517 | 518 | %% @doc Checks if a projection is compatible with the given store. |
518 | 519 | %% |
519 | 520 | %% @private |
520 | 521 |
|
521 | | -check_compatibility_with_store(StoreId, Projection) -> |
| 522 | +check_compatibility_with_store(StoreId, Projection, Timeout) -> |
522 | 523 | case is_single_table_projection(Projection) of |
523 | 524 | true -> |
524 | 525 | ok; |
525 | 526 | false -> |
526 | 527 | %% Ensure the Khepri cluster runs a new enough version to support |
527 | 528 | %% multi-table projections. |
528 | | - Compatible = khepri_machine:does_api_comply_with( |
529 | | - multi_table_projections, StoreId), |
530 | | - case Compatible of |
531 | | - true -> |
532 | | - ok; |
533 | | - false -> |
534 | | - Reason = ?khepri_error( |
535 | | - cluster_incompatible_with_multi_table_projection, |
536 | | - #{store_id => StoreId, |
537 | | - projection => Projection}), |
538 | | - {error, Reason} |
539 | | - end |
| 529 | + khepri_machine:wait_for_effective_behaviour( |
| 530 | + StoreId, multi_table_projections, Timeout) |
540 | 531 | end. |
541 | 532 |
|
542 | 533 | -spec init(Projection) -> Ret when |
|
0 commit comments