diff --git a/mc/Mongo-Core.package/Mongo.class/instance/closeIfOpen.st b/mc/Mongo-Core.package/Mongo.class/instance/closeIfOpen.st new file mode 100644 index 00000000..ef385ccf --- /dev/null +++ b/mc/Mongo-Core.package/Mongo.class/instance/closeIfOpen.st @@ -0,0 +1,3 @@ +operations +closeIfOpen + self isOpen ifTrue: [ self close ] \ No newline at end of file diff --git a/mc/Mongo-Core.package/Mongo.class/instance/isMaster.st b/mc/Mongo-Core.package/Mongo.class/instance/isMaster.st new file mode 100644 index 00000000..bdc3ec9b --- /dev/null +++ b/mc/Mongo-Core.package/Mongo.class/instance/isMaster.st @@ -0,0 +1,3 @@ +operations +isMaster + ^ self admin isMaster \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoDatabase.class/instance/isMaster.st b/mc/Mongo-Core.package/MongoDatabase.class/instance/isMaster.st new file mode 100644 index 00000000..b6a2c5c0 --- /dev/null +++ b/mc/Mongo-Core.package/MongoDatabase.class/instance/isMaster.st @@ -0,0 +1,7 @@ +operations +isMaster + + | reply | + reply := self command: (OrderedDictionary new at: #ismaster put: 1; yourself). + + ^ MongoIsMaster with: reply \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/README.md b/mc/Mongo-Core.package/MongoIsMaster.class/README.md new file mode 100644 index 00000000..07d6107d --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/README.md @@ -0,0 +1,12 @@ +I represent the response of a "isMaster" command, defined by documentation in the following way: + +isMaster returns a document that describes the role of the mongod instance. If the optional field saslSupportedMechs is specified, the command also returns an array of SASL mechanisms used to create the specified user’s credentials. + +If the instance is a member of a replica set, then isMaster returns a subset of the replica set configuration and status including whether or not the instance is the primary of the replica set. + +When sent to a mongod instance that is not a member of a replica set, isMaster returns a subset of this information. + +MongoDB drivers and clients use isMaster to determine the state of the replica set members and to discover additional members of a replica set. + + +Read more at: https://docs.mongodb.com/v4.0/reference/command/isMaster/ \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/class/with..st b/mc/Mongo-Core.package/MongoIsMaster.class/class/with..st new file mode 100644 index 00000000..a7d282e0 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/class/with..st @@ -0,0 +1,5 @@ +instance creation +with: aCollection + ^ self basicNew + initializeWith: aCollection; + yourself \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/hasPrimary.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/hasPrimary.st new file mode 100644 index 00000000..16a8be07 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/hasPrimary.st @@ -0,0 +1,3 @@ +replica set +hasPrimary + ^ response includesKey: 'primary' \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/initializeWith..st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/initializeWith..st new file mode 100644 index 00000000..26161138 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/initializeWith..st @@ -0,0 +1,5 @@ +initialization +initializeWith: aCollection + self initialize. + + response := aCollection. \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/isPrimary.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isPrimary.st new file mode 100644 index 00000000..49c819eb --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isPrimary.st @@ -0,0 +1,3 @@ +replica set +isPrimary + ^ (response at: 'ismaster') and: [ self isReplicaSet ] \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/isReadOnly.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isReadOnly.st new file mode 100644 index 00000000..840fb585 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isReadOnly.st @@ -0,0 +1,3 @@ +accessing +isReadOnly + ^ response at: 'readOnly' \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/isReplicaSet.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isReplicaSet.st new file mode 100644 index 00000000..7812ebb0 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isReplicaSet.st @@ -0,0 +1,3 @@ +replica set +isReplicaSet + ^ response includesKey: 'setName' \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/isSecondary.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isSecondary.st new file mode 100644 index 00000000..99980d66 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isSecondary.st @@ -0,0 +1,3 @@ +replica set +isSecondary + ^ response at: 'secondary' ifAbsent: [ false ] \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/isWrittable.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isWrittable.st new file mode 100644 index 00000000..199b420f --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/isWrittable.st @@ -0,0 +1,9 @@ +accessing +isWrittable + "A boolean value that reports when this node is writable. If true, then this instance is a primary in a replica set, or a mongos instance, or a standalone mongod. + + This field will be false if the instance is a secondary member of a replica set or if the member is an arbiter of a replica set. + +Source: https://docs.mongodb.com/manual/reference/command/isMaster/#isMaster.ismaster" + + ^ response at: 'ismaster' \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/primaryUrlString.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/primaryUrlString.st new file mode 100644 index 00000000..aed86872 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/primaryUrlString.st @@ -0,0 +1,3 @@ +replica set +primaryUrlString + ^ response at: 'primary' \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetHosts.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetHosts.st new file mode 100644 index 00000000..145edb1b --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetHosts.st @@ -0,0 +1,3 @@ +replica set +replicaSetHosts + ^ response at: #hosts \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetName.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetName.st new file mode 100644 index 00000000..871bdded --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetName.st @@ -0,0 +1,3 @@ +replica set +replicaSetName + ^ response at: 'setName' \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetUrls.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetUrls.st new file mode 100644 index 00000000..d13fbc50 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/replicaSetUrls.st @@ -0,0 +1,3 @@ +replica set +replicaSetUrls + ^ self replicaSetHosts collect: #asMongoUrl \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/instance/urlString.st b/mc/Mongo-Core.package/MongoIsMaster.class/instance/urlString.st new file mode 100644 index 00000000..3ec3c287 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/instance/urlString.st @@ -0,0 +1,5 @@ +replica set +urlString + "In a replica set, this is the url of the requested server. Not defined else." + + ^ response at: 'me' \ No newline at end of file diff --git a/mc/Mongo-Core.package/MongoIsMaster.class/properties.json b/mc/Mongo-Core.package/MongoIsMaster.class/properties.json new file mode 100644 index 00000000..bd451f55 --- /dev/null +++ b/mc/Mongo-Core.package/MongoIsMaster.class/properties.json @@ -0,0 +1,13 @@ +{ + "commentStamp" : "MartinDias 7/24/2019 12:23", + "super" : "Object", + "category" : "Mongo-Core-Responses", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ + "response" + ], + "name" : "MongoIsMaster", + "type" : "normal" +} \ No newline at end of file diff --git a/mc/Mongo-Core.package/String.extension/instance/asMongoUrl.st b/mc/Mongo-Core.package/String.extension/instance/asMongoUrl.st new file mode 100644 index 00000000..2bdf7434 --- /dev/null +++ b/mc/Mongo-Core.package/String.extension/instance/asMongoUrl.st @@ -0,0 +1,6 @@ +*Mongo-Core +asMongoUrl + | url | + url := ZnUrl fromString: self defaultScheme: #mongodb. + url hasPort ifFalse: [ url port: 27017 ]. + ^ url \ No newline at end of file diff --git a/mc/Mongo-Core.package/String.extension/properties.json b/mc/Mongo-Core.package/String.extension/properties.json new file mode 100644 index 00000000..b20f2de3 --- /dev/null +++ b/mc/Mongo-Core.package/String.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "String" +} \ No newline at end of file diff --git a/mc/Mongo-Core.package/ZnUrl.extension/instance/asMongoUrl.st b/mc/Mongo-Core.package/ZnUrl.extension/instance/asMongoUrl.st new file mode 100644 index 00000000..9c719dab --- /dev/null +++ b/mc/Mongo-Core.package/ZnUrl.extension/instance/asMongoUrl.st @@ -0,0 +1,4 @@ +*Mongo-Core +asMongoUrl + self assert: (self scheme = #mongodb). + ^self \ No newline at end of file diff --git a/mc/Mongo-Core.package/ZnUrl.extension/properties.json b/mc/Mongo-Core.package/ZnUrl.extension/properties.json new file mode 100644 index 00000000..ed0059c9 --- /dev/null +++ b/mc/Mongo-Core.package/ZnUrl.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "ZnUrl" +} \ No newline at end of file diff --git a/mc/Mongo-Tests-Core.package/MongoNoReplicationTest.class/instance/testIsMaster.st b/mc/Mongo-Tests-Core.package/MongoNoReplicationTest.class/instance/testIsMaster.st new file mode 100644 index 00000000..18e91acd --- /dev/null +++ b/mc/Mongo-Tests-Core.package/MongoNoReplicationTest.class/instance/testIsMaster.st @@ -0,0 +1,15 @@ +tests +testIsMaster + + | response | + response := mongo isMaster. + + "Common API is short." + self deny: response isNil. + self deny: response isReadOnly. + self deny: response isReplicaSet. + + "Replica Set API that works, anyway." + self deny: response hasPrimary. + self deny: response isPrimary. + self deny: response isSecondary. diff --git a/mc/Mongo-Tests-Core.package/MongoReplicationOkTest.class/instance/testIsMaster.st b/mc/Mongo-Tests-Core.package/MongoReplicationOkTest.class/instance/testIsMaster.st new file mode 100644 index 00000000..53a1b6e5 --- /dev/null +++ b/mc/Mongo-Tests-Core.package/MongoReplicationOkTest.class/instance/testIsMaster.st @@ -0,0 +1,18 @@ +tests +testIsMaster + + | response | + response := mongo isMaster. + + "Common API is short." + self deny: response isNil. + self deny: response isReadOnly. + self assert: response isReplicaSet. + + "Replica Set specific API." + self assert: response hasPrimary. + self assert: response isPrimary. + self deny: response isSecondary. + self assert: response urlString equals: mongo host, ':', mongo port asString. + self assert: response primaryUrlString equals: response urlString. + self assert: response replicaSetHosts equals: #('localhost:27031' 'localhost:27032'). diff --git a/mc/Mongo-Tests-Core.package/MongoReplicationTest.class/instance/tearDown.st b/mc/Mongo-Tests-Core.package/MongoReplicationTest.class/instance/tearDown.st index dc554f35..752e2bba 100644 --- a/mc/Mongo-Tests-Core.package/MongoReplicationTest.class/instance/tearDown.st +++ b/mc/Mongo-Tests-Core.package/MongoReplicationTest.class/instance/tearDown.st @@ -1,4 +1,4 @@ running tearDown super tearDown. - (mongo isNotNil and: [mongo isOpen]) ifTrue: [mongo close]. \ No newline at end of file + mongo ifNotNil: [ mongo closeIfOpen ]. \ No newline at end of file