Skip to content

Commit c79f57c

Browse files
committed
PHPC-981: Move APM functions to MongoDB\Driver\Monitoring namespace
1 parent c08f056 commit c79f57c

19 files changed

+104
-92
lines changed

config.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ if test "$MONGODB" != "no"; then
193193
src/MongoDB/Exception/SSLConnectionException.c \
194194
src/MongoDB/Exception/UnexpectedValueException.c \
195195
src/MongoDB/Exception/WriteException.c \
196-
src/MongoDB/Monitoring.c \
197196
src/MongoDB/Monitoring/CommandFailedEvent.c \
198197
src/MongoDB/Monitoring/CommandStartedEvent.c \
199198
src/MongoDB/Monitoring/CommandSubscriber.c \
200199
src/MongoDB/Monitoring/CommandSucceededEvent.c \
201-
src/MongoDB/Monitoring/Subscriber.c
200+
src/MongoDB/Monitoring/Subscriber.c \
201+
src/MongoDB/Monitoring/functions.c
202202
"
203203

204204
PHP_ARG_WITH(libbson, whether to use system libbson,

config.w32

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ if (PHP_MONGODB != "no") {
8585
EXTENSION("mongodb", "php_phongo.c phongo_compat.c", null, PHP_MONGODB_CFLAGS);
8686
ADD_SOURCES(configure_module_dirname + "/src", "bson.c bson-encode.c", "mongodb");
8787
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Binary.c Decimal128.c Javascript.c MaxKey.c MinKey.c ObjectID.c Persistable.c Regex.c Serializable.c Timestamp.c Type.c TypeWrapper.c Unserializable.c UTCDateTime.c", "mongodb");
88-
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "BulkWrite.c Command.c Cursor.c CursorId.c Manager.c Monitoring.c Query.c ReadConcern.c ReadPreference.c Server.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
88+
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "BulkWrite.c Command.c Cursor.c CursorId.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
8989
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c ConnectionException.c ConnectionTimeoutException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c", "mongodb");
90-
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c Subscriber.c", "mongodb");
90+
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c Subscriber.c functions.c", "mongodb");
9191
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/bson", PHP_MONGODB_BSON_SOURCES, "mongodb");
9292
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/jsonsl", PHP_MONGODB_JSONSL_SOURCES, "mongodb");
9393
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", PHP_MONGODB_MONGOC_SOURCES, "mongodb");

php_phongo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
/* Our stuffz */
6868
#include "php_phongo.h"
6969
#include "php_bson.h"
70-
#include "src/MongoDB/Monitoring.h"
70+
#include "src/MongoDB/Monitoring/functions.h"
7171

7272
#undef MONGOC_LOG_DOMAIN
7373
#define MONGOC_LOG_DOMAIN "PHONGO"
@@ -2424,8 +2424,8 @@ static const zend_function_entry mongodb_functions[] = {
24242424
ZEND_NS_NAMED_FE("MongoDB\\BSON", toJSON, PHP_FN(MongoDB_BSON_toJSON), ai_bson_toJSON)
24252425
ZEND_NS_NAMED_FE("MongoDB\\BSON", toExtendedJSON, PHP_FN(MongoDB_BSON_toExtendedJSON), ai_bson_toExtendedJSON)
24262426
ZEND_NS_NAMED_FE("MongoDB\\BSON", fromJSON, PHP_FN(MongoDB_BSON_fromJSON), ai_bson_fromJSON)
2427-
ZEND_NS_NAMED_FE("MongoDB\\Monitoring", addSubscriber, PHP_FN(MongoDB_Monitoring_addSubscriber), ai_Monitoring_addSubscriber)
2428-
ZEND_NS_NAMED_FE("MongoDB\\Monitoring", removeSubscriber, PHP_FN(MongoDB_Monitoring_removeSubscriber), ai_Monitoring_removeSubscriber)
2427+
ZEND_NS_NAMED_FE("MongoDB\\Driver\\Monitoring", addSubscriber, PHP_FN(MongoDB_Driver_Monitoring_addSubscriber), ai_Monitoring_addSubscriber)
2428+
ZEND_NS_NAMED_FE("MongoDB\\Driver\\Monitoring", removeSubscriber, PHP_FN(MongoDB_Driver_Monitoring_removeSubscriber), ai_Monitoring_removeSubscriber)
24292429
PHP_FE_END
24302430
};
24312431
/* }}} */

src/MongoDB/Monitoring.h

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
/*
2-
* Copyright 2014-2017 MongoDB, Inc.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* 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-
*/
2+
+---------------------------------------------------------------------------+
3+
| PHP Driver for MongoDB |
4+
+---------------------------------------------------------------------------+
5+
| Copyright 2016-2016 MongoDB, Inc. |
6+
| |
7+
| Licensed under the Apache License, Version 2.0 (the "License"); |
8+
| you may not use this file except in compliance with the License. |
9+
| You may obtain a copy of the License at |
10+
| |
11+
| http://www.apache.org/licenses/LICENSE-2.0 |
12+
| |
13+
| Unless required by applicable law or agreed to in writing, software |
14+
| distributed under the License is distributed on an "AS IS" BASIS, |
15+
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16+
| See the License for the specific language governing permissions and |
17+
| limitations under the License. |
18+
+---------------------------------------------------------------------------+
19+
| Copyright (c) 2016-2016 MongoDB, Inc. |
20+
+---------------------------------------------------------------------------+
21+
*/
1622

1723
#ifdef HAVE_CONFIG_H
1824
# include "config.h"
@@ -34,9 +40,9 @@ static char *php_phongo_make_subscriber_hash(zval *subscriber TSRMLS_DC)
3440
return hash;
3541
}
3642

37-
/* {{{ proto void MongoDB\Monitoring::addSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber)
43+
/* {{{ proto void MongoDB\Driver\Monitoring\addSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber)
3844
Adds a monitoring subscriber to the set of subscribers */
39-
PHP_FUNCTION(MongoDB_Monitoring_addSubscriber)
45+
PHP_FUNCTION(MongoDB_Driver_Monitoring_addSubscriber)
4046
{
4147
zval *zSubscriber = NULL;
4248
char *hash;
@@ -59,6 +65,7 @@ PHP_FUNCTION(MongoDB_Monitoring_addSubscriber)
5965
}
6066

6167
hash = php_phongo_make_subscriber_hash(zSubscriber TSRMLS_CC);
68+
6269
/* If we have already stored the subscriber, bail out. Otherwise, add
6370
* subscriber to list */
6471
#if PHP_VERSION_ID >= 70000
@@ -81,9 +88,9 @@ PHP_FUNCTION(MongoDB_Monitoring_addSubscriber)
8188
}
8289
/* }}} */
8390

84-
/* {{{ proto void MongoDB\Monitoring::removeSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber)
91+
/* {{{ proto void MongoDB\Driver\Monitoring\removeSubscriber(MongoDB\Driver\Monitoring\Subscriber $subscriber)
8592
Removes a monitoring subscriber from the set of subscribers */
86-
PHP_FUNCTION(MongoDB_Monitoring_removeSubscriber)
93+
PHP_FUNCTION(MongoDB_Driver_Monitoring_removeSubscriber)
8794
{
8895
zval *zSubscriber = NULL;
8996
char *hash;

src/MongoDB/Monitoring/functions.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
+---------------------------------------------------------------------------+
3+
| PHP Driver for MongoDB |
4+
+---------------------------------------------------------------------------+
5+
| Copyright 2016-2016 MongoDB, Inc. |
6+
| |
7+
| Licensed under the Apache License, Version 2.0 (the "License"); |
8+
| you may not use this file except in compliance with the License. |
9+
| You may obtain a copy of the License at |
10+
| |
11+
| http://www.apache.org/licenses/LICENSE-2.0 |
12+
| |
13+
| Unless required by applicable law or agreed to in writing, software |
14+
| distributed under the License is distributed on an "AS IS" BASIS, |
15+
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16+
| See the License for the specific language governing permissions and |
17+
| limitations under the License. |
18+
+---------------------------------------------------------------------------+
19+
| Copyright (c) 2016-2016 MongoDB, Inc. |
20+
+---------------------------------------------------------------------------+
21+
*/
22+
23+
#ifndef PHONGO_MONITORING_FUNCTIONS_H
24+
#define PHONGO_MONITORING_FUNCTIONS_H
25+
26+
#include <php.h>
27+
28+
PHP_FUNCTION(MongoDB_Driver_Monitoring_addSubscriber);
29+
PHP_FUNCTION(MongoDB_Driver_Monitoring_removeSubscriber);
30+
31+
#endif /* PHONGO_MONITORING_FUNCTIONS_H */
32+
33+
34+
/*
35+
* Local variables:
36+
* tab-width: 4
37+
* c-basic-offset: 4
38+
* End:
39+
* vim600: noet sw=4 ts=4 fdm=marker
40+
* vim<600: noet sw=4 ts=4
41+
*/

tests/apm/bug0950-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $bulk->insert(['_id' => 2]);
3333
$bulk->insert(['_id' => 3]);
3434
$manager->executeBulkWrite(NS, $bulk);
3535

36-
MongoDB\Monitoring\addSubscriber(new MySubscriber);
36+
MongoDB\Driver\Monitoring\addSubscriber(new MySubscriber);
3737

3838
$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query([], ['batchSize' => 2]));
3939

tests/apm/Manager_addSubscriber-001.phpt renamed to tests/apm/monitoring-addSubscriber-001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
APM: Manager::addSubscriber() (single)
2+
MongoDB\Driver\Monitoring\addSubscriber(): Adding one subscriber
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
55
--FILE--
@@ -31,7 +31,7 @@ $subscriber = new MySubscriber;
3131
echo "Before addSubscriber\n";
3232
$cursor = $m->executeQuery( "demo.test", $query );
3333

34-
MongoDB\Monitoring\addSubscriber( $subscriber );
34+
MongoDB\Driver\Monitoring\addSubscriber( $subscriber );
3535

3636
echo "After addSubscriber\n";
3737
$cursor = $m->executeQuery( "demo.test", $query );

tests/apm/Manager_addSubscriber-002.phpt renamed to tests/apm/monitoring-addSubscriber-002.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
APM: Manager::addSubscriber() (multiple)
2+
MongoDB\Driver\Monitoring\addSubscriber(): Adding two subscribers
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
55
--FILE--
@@ -39,12 +39,12 @@ $subscriber2 = new MySubscriber( "TWO" );
3939
echo "Before addSubscriber\n";
4040
$cursor = $m->executeQuery( "demo.test", $query );
4141

42-
MongoDB\Monitoring\addSubscriber( $subscriber1 );
42+
MongoDB\Driver\Monitoring\addSubscriber( $subscriber1 );
4343

4444
echo "After addSubscriber (ONE)\n";
4545
$cursor = $m->executeQuery( "demo.test", $query );
4646

47-
MongoDB\Monitoring\addSubscriber( $subscriber2 );
47+
MongoDB\Driver\Monitoring\addSubscriber( $subscriber2 );
4848

4949
echo "After addSubscriber (TWO)\n";
5050
$cursor = $m->executeQuery( "demo.test", $query );

tests/apm/Manager_addSubscriber-003.phpt renamed to tests/apm/monitoring-addSubscriber-003.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
APM: Manager::addSubscriber() (duplicate)
2+
MongoDB\Driver\Monitoring\addSubscriber(): Adding one subscriber multiple times
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
55
--FILE--
@@ -30,12 +30,12 @@ $subscriber = new MySubscriber();
3030
echo "Before addSubscriber\n";
3131
$cursor = $m->executeQuery( "demo.test", $query );
3232

33-
MongoDB\Monitoring\addSubscriber( $subscriber );
33+
MongoDB\Driver\Monitoring\addSubscriber( $subscriber );
3434

3535
echo "After addSubscriber\n";
3636
$cursor = $m->executeQuery( "demo.test", $query );
3737

38-
MongoDB\Monitoring\addSubscriber( $subscriber );
38+
MongoDB\Driver\Monitoring\addSubscriber( $subscriber );
3939

4040
echo "After addSubscriber\n";
4141
$cursor = $m->executeQuery( "demo.test", $query );

0 commit comments

Comments
 (0)