@@ -126,8 +126,86 @@ module Atomic_write (K : Irmin.Type.S) (V : Irmin.Type.S) = struct
126126end
127127
128128module Content_addressable = Irmin.Content_addressable. Make (Append_only )
129- module Maker = Irmin. Maker (Content_addressable ) (Atomic_write )
130- module KV = Irmin. KV_maker (Content_addressable ) (Atomic_write )
129+
130+ module Make
131+ (CA : Irmin.Content_addressable.Maker )
132+ (AW : Irmin.Atomic_write.Maker ) =
133+ struct
134+ module type Config = sig
135+ val suffix : string
136+ end
137+
138+ module Indexable_store (S : Config ) = struct
139+ type 'h key = 'h
140+
141+ module Key = Irmin.Key. Of_hash
142+
143+ module Make (Hash : Irmin.Hash.S ) (Value : Irmin.Type.S ) = struct
144+ module CA = Irmin.Content_addressable. Check_closed (CA ) (Hash ) (Value )
145+ include Irmin.Indexable. Of_content_addressable (Hash ) (CA )
146+
147+ let v config =
148+ let root = Irmin.Backend.Conf. get config Conf.Key. root in
149+ let suffix = S. suffix in
150+ let config =
151+ Irmin.Backend.Conf. add config Conf.Key. root (root ^ " /" ^ suffix)
152+ in
153+ CA. v config
154+ end
155+ end
156+
157+ module Atomic_write (S : Config ) (Hash : Irmin.Type.S ) (Value : Irmin.Type.S ) =
158+ struct
159+ module AW = Irmin.Atomic_write. Check_closed (AW ) (Hash ) (Value )
160+ include AW
161+
162+ let v config =
163+ let root = Irmin.Backend.Conf. get config Conf.Key. root in
164+ let suffix = S. suffix in
165+ let config =
166+ Irmin.Backend.Conf. add config Conf.Key. root (root ^ " /" ^ suffix)
167+ in
168+ AW. v config
169+ end
170+
171+ module Maker_args = struct
172+ module Contents_store =
173+ Irmin.Indexable. Maker_concrete_key2_of_1 (Indexable_store (struct
174+ let suffix = " contents"
175+ end ))
176+
177+ module Node_store = Indexable_store (struct
178+ let suffix = " node"
179+ end )
180+
181+ module Commit_store = Indexable_store (struct
182+ let suffix = " commit"
183+ end )
184+
185+ module Branch_store = Atomic_write (struct
186+ let suffix = " branch"
187+ end )
188+ end
189+
190+ include Irmin.Generic_key. Maker (Maker_args )
191+ end
192+
193+ module Maker = Make (Content_addressable ) (Atomic_write )
194+
195+ module KV_maker
196+ (CA : Irmin.Content_addressable.Maker )
197+ (AW : Irmin.Atomic_write.Maker ) =
198+ struct
199+ type metadata = unit
200+ type hash = Irmin.Schema .default_hash
201+ type info = Irmin.Info .default
202+
203+ module Maker = Maker
204+ include Maker
205+ module Make (C : Irmin.Contents .S ) = Maker .Make (Irmin.Schema .KV (C ))
206+ end
207+
208+ module KV = KV_maker (Content_addressable ) (Atomic_write )
131209
132210(* Enforce that {!S} is a sub-type of {!Irmin.Maker}. *)
133211module Maker_is_a_maker : Irmin .Maker = Maker
0 commit comments