21
21
-export ([start /4 , stop /2 , client_init /5 , successfully_recovered_state /2 ]).
22
22
23
23
24
- start (VHost , Type , ClientRefs , StartupFunState ) when is_list ( ClientRefs );
25
- ClientRefs == undefined ->
24
+ start (VHost , Type , ClientRefs , StartupFunState , MsgStoreModule )
25
+ when is_list ( ClientRefs ); ClientRefs == undefined ->
26
26
case rabbit_vhost_sup_sup :vhost_sup (VHost ) of
27
27
{ok , VHostSup } ->
28
+ ets :insert (rabbit_vhost_sup_sup , {{VHost , Type }, MsgStoreModule }),
28
29
VHostDir = rabbit_vhost :msg_store_dir_path (VHost ),
29
30
supervisor2 :start_child (VHostSup ,
30
31
{Type , {rabbit_msg_store , start_link ,
31
- [Type , VHostDir , ClientRefs , StartupFunState ]},
32
+ [Type , VHostDir , ClientRefs ,
33
+ StartupFunState , MsgStoreModule ]},
32
34
transient , ? WORKER_WAIT , worker , [rabbit_msg_store ]});
33
35
% % we can get here if a vhost is added and removed concurrently
34
36
% % e.g. some integration tests do it
@@ -52,16 +54,19 @@ stop(VHost, Type) ->
52
54
end .
53
55
54
56
client_init (VHost , Type , Ref , MsgOnDiskFun , CloseFDsFun ) ->
55
- with_vhost_store (VHost , Type , fun (StorePid ) ->
56
- rabbit_msg_store :client_init (StorePid , Ref , MsgOnDiskFun , CloseFDsFun )
57
+ with_vhost_store (VHost , Type , fun (StorePid , MsgStoreModule ) ->
58
+ MsgStoreModule :client_init (StorePid , Ref , MsgOnDiskFun , CloseFDsFun )
57
59
end ).
58
60
59
61
with_vhost_store (VHost , Type , Fun ) ->
60
62
case vhost_store_pid (VHost , Type ) of
61
63
no_pid ->
62
64
throw ({message_store_not_started , Type , VHost });
63
65
Pid when is_pid (Pid ) ->
64
- Fun (Pid )
66
+ case ets :lookup (rabbit_vhost_sup_sup , {VHost , Type }) of
67
+ [MsgStoreModule ] -> Fun (Pid , MsgStoreModule );
68
+ [] -> error ({message_store_module_not_found , {VHost , Type , Pid }})
69
+ end
65
70
end .
66
71
67
72
vhost_store_pid (VHost , Type ) ->
@@ -72,6 +77,6 @@ vhost_store_pid(VHost, Type) ->
72
77
end .
73
78
74
79
successfully_recovered_state (VHost , Type ) ->
75
- with_vhost_store (VHost , Type , fun (StorePid ) ->
76
- rabbit_msg_store :successfully_recovered_state (StorePid )
80
+ with_vhost_store (VHost , Type , fun (StorePid , MsgStoreModule ) ->
81
+ MsgStoreModule :successfully_recovered_state (StorePid )
77
82
end ).
0 commit comments