1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*  Fluent Bit
4  *  ==========
5  *  Copyright (C) 2019      The Fluent Bit Authors
6  *  Copyright (C) 2015-2018 Treasure Data Inc.
7  *
8  *  Licensed under the Apache License, Version 2.0 (the "License");
9  *  you may not use this file except in compliance with the License.
10  *  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *  Unless required by applicable law or agreed to in writing, software
15  *  distributed under the License is distributed on an "AS IS" BASIS,
16  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *  See the License for the specific language governing permissions and
18  *  limitations under the License.
19  */
20 
21 #ifndef FLB_SP_SNAPSHOT_H
22 #define FLB_SP_SNAPSHOT_H
23 
24 #define SNAPSHOT_PAGE_SIZE 1024
25 
26 struct flb_sp_snapshot_page {
27     int records;
28     int start_pos;          /* Start position of the valid data */
29     int end_pos;            /* End position of the valid data */
30     char *snapshot_page;
31     struct mk_list _head;
32 };
33 
34 struct flb_sp_snapshot {
35     int time_limit;
36     int record_limit;
37     int records;
38     size_t size;
39     struct mk_list pages;
40 };
41 
42 int flb_sp_snapshot_update(struct flb_sp_task *task, const char *buf_data,
43                            size_t buf_size, struct flb_time *tms);
44 
45 int flb_sp_snapshot_flush(struct flb_sp *sp, struct flb_sp_task *task,
46                           char **out_buf_data, size_t *out_buf_size);
47 
48 void flb_sp_snapshot_destroy(struct flb_sp_snapshot *snapshot);
49 
50 #endif
51