Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
md_status.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef md_status_h
18 #define md_status_h
19 
20 struct md_json_t;
21 struct md_reg_t;
22 struct md_result_t;
23 struct md_ocsp_reg_t;
24 
25 #include "md_store.h"
26 
30 apr_status_t md_status_get_md_json(struct md_json_t **pjson, const md_t *md,
31  struct md_reg_t *reg, struct md_ocsp_reg_t *ocsp,
32  apr_pool_t *p);
33 
38  struct md_reg_t *reg, struct md_ocsp_reg_t *ocsp,
39  apr_pool_t *p);
40 
46 void md_status_take_stock(struct md_json_t **pjson, apr_array_header_t *mds,
47  struct md_reg_t *reg, apr_pool_t *p);
48 
49 
50 typedef struct md_job_t md_job_t;
51 
52 struct md_job_t {
53  md_store_group_t group;/* group where job is persisted */
54  const char *mdomain; /* Name of the MD this job is about */
55  md_store_t *store; /* store where it is persisted */
57  apr_time_t next_run; /* Time this job wants to be processed next */
58  apr_time_t last_run; /* Time this job ran last (or 0) */
59  struct md_result_t *last_result; /* Result from last run */
60  int finished; /* true iff the job finished successfully */
61  int notified; /* true iff notifications were handled successfully */
62  apr_time_t valid_from; /* at which time the finished job results become valid, 0 if immediate */
63  int error_runs; /* Number of errored runs of an unfinished job */
64  int fatal_error; /* a fatal error is remedied by retrying */
65  md_json_t *log; /* array of log objects with minimum fields
66  MD_KEY_WHEN (timestamp) and MD_KEY_TYPE (string) */
67  apr_size_t max_log; /* max number of log entries, new ones replace oldest */
68  int dirty;
70 
72  void *notify_ctx;
73 };
74 
80  md_store_group_t group, const char *name);
81 
83 
88 
93 
100 void md_job_log_append(md_job_t *job, const char *type,
101  const char *status, const char *detail);
102 
106 md_json_t *md_job_log_get_latest(md_job_t *job, const char *type);
107 
112 apr_time_t md_job_log_get_time_of_latest(md_job_t *job, const char *type);
113 
114 void md_job_start_run(md_job_t *job, struct md_result_t *result, md_store_t *store);
115 void md_job_end_run(md_job_t *job, struct md_result_t *result);
116 void md_job_retry_at(md_job_t *job, apr_time_t later);
117 
118 /* Given the number of errors encountered, recommend a delay for the next attempt */
119 apr_time_t md_job_delay_on_errors(int err_count);
120 
121 void md_job_set_notify_cb(md_job_t *job, md_job_notify_cb *cb, void *baton);
122 apr_status_t md_job_notify(md_job_t *job, const char *reason, struct md_result_t *result);
123 /* Same as notify but without checks on success and no change to job */
124 void md_job_holler(md_job_t *job, const char *reason);
125 
126 #endif /* md_status_h */
size_t apr_size_t
Definition: apr.h:397
apr_time_t valid_from
Definition: md_status.h:62
Definition: md.h:74
Definition: md_store.h:278
struct md_json_t md_json_t
Definition: md_json.h:29
apr_status_t md_status_get_json(struct md_json_t **pjson, apr_array_header_t *mds, struct md_reg_t *reg, struct md_ocsp_reg_t *ocsp, apr_pool_t *p)
apr_time_t md_job_delay_on_errors(int err_count)
Definition: apr_tables.h:62
md_store_t * store
Definition: md_status.h:55
md_store_group_t
Definition: md_store.h:61
md_job_t * md_job_make(apr_pool_t *p, md_store_t *store, md_store_group_t group, const char *name)
int finished
Definition: md_status.h:60
void md_job_set_group(md_job_t *job, md_store_group_t group)
apr_time_t next_run
Definition: md_status.h:57
const char * detail
Definition: md_result.h:32
int error_runs
Definition: md_status.h:63
apr_status_t md_job_notify_cb(struct md_job_t *job, const char *reason, struct md_result_t *result, apr_pool_t *p, void *baton)
Definition: md.h:294
apr_status_t md_job_load(md_job_t *job)
Definition: md_status.h:52
const char * mdomain
Definition: md_status.h:54
apr_int64_t apr_time_t
Definition: apr_time.h:45
void md_job_start_run(md_job_t *job, struct md_result_t *result, md_store_t *store)
void md_job_log_append(md_job_t *job, const char *type, const char *status, const char *detail)
apr_status_t md_job_save(md_job_t *job, struct md_result_t *result, apr_pool_t *p)
void md_status_take_stock(struct md_json_t **pjson, apr_array_header_t *mds, struct md_reg_t *reg, apr_pool_t *p)
md_json_t * log
Definition: md_status.h:65
int dirty
Definition: md_status.h:68
const char const dav_liveprop_group * group
Definition: mod_dav.h:1048
apr_size_t max_log
Definition: md_status.h:67
void md_job_holler(md_job_t *job, const char *reason)
apr_status_t md_job_notify(md_job_t *job, const char *reason, struct md_result_t *result)
apr_time_t md_job_log_get_time_of_latest(md_job_t *job, const char *type)
md_job_notify_cb * notify
Definition: md_status.h:71
apr_time_t last_run
Definition: md_status.h:58
Definition: md_result.h:27
struct md_reg_t md_reg_t
Definition: md_reg.h:32
apr_status_t md_status_get_md_json(struct md_json_t **pjson, const md_t *md, struct md_reg_t *reg, struct md_ocsp_reg_t *ocsp, apr_pool_t *p)
apr_pool_t * p
int notified
Definition: md_status.h:61
apr_pool_t * p
Definition: md_status.h:56
int status
Definition: mod_dav.h:141
struct md_ocsp_reg_t md_ocsp_reg_t
Definition: md_ocsp.h:35
const char * name
Definition: mod_dav.h:805
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
md_store_group_t group
Definition: md_status.h:53
int apr_status_t
Definition: apr_errno.h:44
md_json_t * md_job_log_get_latest(md_job_t *job, const char *type)
struct md_result_t * last_result
Definition: md_status.h:59
void md_job_end_run(md_job_t *job, struct md_result_t *result)
void * notify_ctx
Definition: md_status.h:72
void md_job_retry_at(md_job_t *job, apr_time_t later)
int fatal_error
Definition: md_status.h:64
struct md_result_t * observing
Definition: md_status.h:69
void md_job_set_notify_cb(md_job_t *job, md_job_notify_cb *cb, void *baton)