@@ -27,78 +27,117 @@ interface MongoDBCAPI extends Library {
27
27
28
28
// CHECKSTYLE.OFF: MethodName
29
29
/**
30
- * Initializes the mongodbcapi library, required before any other call. Cannot be called again
31
- * without libmongodbcapi_fini() being called first.
30
+ * Creates a status pointer
32
31
*
33
- * @param initParams the embedded mongod initialization parameters.
32
+ * @return the status pointer from which to get an associated status code / error information.
33
+ */
34
+ Pointer libmongodbcapi_status_create ();
34
35
35
- * @note This function is not thread safe.
36
- * @return the error, or 0 if success
36
+ /**
37
+ * Destroys a valid status pointer object.
38
+ *
39
+ * @param status the `libmongodbcapi_status` pointer to release.
37
40
*/
38
- int libmongodbcapi_init (Structure initParams );
41
+
42
+ void libmongodbcapi_status_destroy (Pointer status );
39
43
40
44
/**
41
- * Tears down the state of the library, all databases must be closed before calling this.
45
+ * Gets an error code from a status pointer.
46
+ *
47
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
48
+ * @return The error code associated with the `status` parameter or 0 if successful.
42
49
*
43
- * @return the error, or 0 if success
44
50
*/
45
- int libmongodbcapi_fini ( );
51
+ int libmongodbcapi_status_get_error ( Pointer status );
46
52
47
53
/**
48
- * Create a new db instance .
54
+ * Gets a descriptive error message from a status pointer .
49
55
*
50
- * @param yamlConfig null-terminated YAML formatted MongoDB configuration string
51
- * @return the db pointer
56
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated error message.
57
+ *
58
+ * @return A null-terminated string containing an error message.
52
59
*/
53
- Pointer libmongodbcapi_db_new ( String yamlConfig );
60
+ String libmongodbcapi_status_get_explanation ( Pointer status );
54
61
55
62
/**
56
- * Destroy a db instance .
63
+ * Gets a status code from a status pointer .
57
64
*
58
- * @param db the db pointer
65
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
66
+ * @return A numeric status code associated with the `status` parameter which indicates a
67
+ * sub-category of failure.
59
68
*/
60
- void libmongodbcapi_db_destroy (Pointer db );
69
+ int libmongodbcapi_status_get_code (Pointer status );
61
70
62
71
/**
63
- * Pump the message queue.
72
+ * Initializes the mongodbcapi library, required before any other call.
73
+ *
74
+ * <p>Cannot be called again without {@link #libmongodbcapi_lib_fini(Pointer, Pointer)} being called first.</p>
64
75
*
65
- * @param db the db pointer
66
- * @return the error, or 0 if success
76
+ * @param initParams the embedded mongod initialization parameters.
77
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
78
+ * @return the lib pointer or null if there was a failure. Modifies the status on failure.
67
79
*/
68
- int libmongodbcapi_db_pump ( Pointer db );
80
+ Pointer libmongodbcapi_lib_init ( Structure initParams , Pointer status );
69
81
70
82
/**
71
- * Create a new client instance .
83
+ * Tears down the state of the library, all databases must be closed before calling this .
72
84
*
73
- * @param db the db pointer
74
- * @return the client pointer
85
+ * @param lib the `libmongodbcapi_lib` pointer
86
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
87
+ * @return the error code or 0 if successful. Modifies the status on failure.
75
88
*/
76
- Pointer libmongodbcapi_db_client_new (Pointer db );
89
+ int libmongodbcapi_lib_fini (Pointer lib , Pointer status );
77
90
78
91
/**
79
- * Destroy a client instance.
92
+ * Creates an embedded MongoDB instance and returns a handle with the service context .
80
93
*
81
- * @param client the client pointer
94
+ * @param lib the `libmongodbcapi_lib` pointer
95
+ * @param yamlConfig null-terminated YAML formatted MongoDB configuration string
96
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
97
+ * @return the instance pointer or null if there was a failure. Modifies the status on failure.
82
98
*/
83
- void libmongodbcapi_db_client_destroy (Pointer client );
99
+ Pointer libmongodbcapi_instance_create (Pointer lib , String yamlConfig , Pointer status );
100
+
101
+ /**
102
+ * Shuts down an embedded MongoDB instance.
103
+ *
104
+ * @param instance the `libmongodbcapi_instance` pointer to be destroyed.
105
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
106
+ * @return the error code or 0 if successful. Modifies the status on failure.
107
+ */
108
+ int libmongodbcapi_instance_destroy (Pointer instance , Pointer status );
109
+
110
+ /**
111
+ * Create a new embedded client instance.
112
+ *
113
+ * @param instance the `libmongodbcapi_instance` pointer.
114
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
115
+ * @return the client pointer or null if there was a failure. Modifies the status on failure.
116
+ */
117
+ Pointer libmongodbcapi_client_create (Pointer instance , Pointer status );
118
+
119
+ /**
120
+ * Destroys an embedded client instance.
121
+ *
122
+ * @param client the `libmongodbcapi_client` pointer.
123
+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
124
+ * @return the error code or 0 if successful. Modifies the status on failure.
125
+ */
126
+ int libmongodbcapi_client_destroy (Pointer client , Pointer status );
84
127
85
128
/**
86
129
* Make an RPC call. Not clear yet on whether this is the correct signature.
87
130
*
88
- * @param client the client pointer
131
+ * @param client the `libmongodbcapi_client` pointer
89
132
* @param input the RPC input
90
133
* @param inputSize the RPC input size
91
134
* @param output the RPC output
92
135
* @param outputSize the RPC output size
93
- * @return the error, or 0 if success
136
+ * @param status status the `libmongodbcapi_status` pointer from which to get an associated status code.
137
+ * @return the error code or 0 if successful. Modifies the status on failure.
94
138
*/
95
- int libmongodbcapi_db_client_wire_protocol_rpc (Pointer client , byte [] input , int inputSize , PointerByReference output ,
96
- IntByReference outputSize );
139
+ int libmongodbcapi_client_invoke (Pointer client , byte [] input , int inputSize , PointerByReference output , IntByReference outputSize ,
140
+ Pointer status );
141
+
97
142
98
- /**
99
- * Gets the last error.
100
- *
101
- * @return the last error
102
- */
103
- int libmongodbcapi_get_last_error ();
104
143
}
0 commit comments