9
9
10
10
-include (" osiris.hrl" ).
11
11
-export ([
12
- write /3 ,
12
+ write /4 ,
13
13
write_tracking /3 ,
14
14
read_tracking /2 ,
15
+ fetch_writer_seq /2 ,
15
16
init_reader /2 ,
16
17
register_offset_listener /2 ,
17
18
register_offset_listener /3 ,
50
51
-type retention_spec () :: {max_bytes , non_neg_integer ()} |
51
52
{max_age , milliseconds ()}.
52
53
54
+ -type writer_id () :: binary ().
55
+ -type data () :: iodata () |
56
+ {batch , non_neg_integer (), 0 , iodata ()}.
57
+
53
58
-export_type ([
54
59
state / 0 ,
55
60
config / 0 ,
56
61
offset / 0 ,
57
62
epoch / 0 ,
58
63
tail_info / 0 ,
59
64
offset_spec / 0 ,
60
- retention_spec / 0
65
+ retention_spec / 0 ,
66
+ milliseconds / 0 ,
67
+ writer_id / 0 ,
68
+ data / 0
61
69
]).
62
70
63
71
-spec start_cluster (config ()) ->
@@ -97,8 +105,12 @@ start_writer(Config) ->
97
105
start_replica (Replica , Config ) ->
98
106
osiris_replica :start (Replica , Config ).
99
107
100
- write (Pid , Corr , Data ) ->
101
- osiris_writer :write (Pid , self (), Corr , Data ).
108
+ -spec write (Pid :: pid (),
109
+ WriterId :: binary () | undefined ,
110
+ CorrOrSeq :: non_neg_integer () | term (),
111
+ Data :: data ()) -> ok .
112
+ write (Pid , WriterId , Corr , Data ) ->
113
+ osiris_writer :write (Pid , self (), WriterId , Corr , Data ).
102
114
103
115
-spec write_tracking (pid (), binary (), offset ()) -> ok .
104
116
write_tracking (Pid , TrackingId , Offset ) ->
@@ -108,6 +120,18 @@ write_tracking(Pid, TrackingId, Offset) ->
108
120
read_tracking (Pid , TrackingId ) ->
109
121
osiris_writer :read_tracking (Pid , TrackingId ).
110
122
123
+ -spec fetch_writer_seq (pid (), binary ()) ->
124
+ non_neg_integer () | undefined .
125
+ fetch_writer_seq (Pid , WriterId ) when is_pid (Pid ) andalso is_binary (WriterId ) ->
126
+ osiris_writer :query_writers (Pid ,
127
+ fun (W ) ->
128
+ case maps :get (WriterId , W , undefined ) of
129
+ undefined -> undefined ;
130
+ {_ , _ , Seq } ->
131
+ Seq
132
+ end
133
+ end ).
134
+
111
135
% % @doc Initialise a new offset reader
112
136
% % @param Pid the pid of a writer or replica process
113
137
% % @param OffsetSpec specifies where in the log to attach the reader
0 commit comments