Skip to content

Commit

Permalink
Merge pull request dart-backend#136 from dukefirehawk/feature/rethinkdb
Browse files Browse the repository at this point in the history
Feature/rethinkdb
  • Loading branch information
dukefirehawk authored Jul 6, 2024
2 parents 07ea5fe + 184fd15 commit 3f04946
Show file tree
Hide file tree
Showing 25 changed files with 780 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"image": "dart:3.0",
"image": "dart:3.4",
"forwardPorts": [3000,5000],
"features": {
}
Expand Down
21 changes: 21 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@
docker logs docker-mongo-1 -f
```

## rethinkDB

### Starting the rethinkDB container

```bash
docker compose -f docker-compose-rethinkdb.yml up -d
```

### Stopping the rethinkDB container

```bash
docker compose -f docker-compose-rethinkdb.yml stop
docker compose -f docker-compose-rethinkdb.yml down
```

### Checking the rethinkDB container log

```bash
docker logs docker-rethinkdb-1 -f
```

## Redis

### Starting the Redis container
Expand Down
11 changes: 5 additions & 6 deletions docker/docker-compose-mongo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ services:
ports:
- 27017:27017
environment:
#MONGO_INITDB_ROOT_USERNAME: root
#MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: Qwerty
MONGO_INITDB_DATABASE: local
volumes:
- "mongo:/data/db"
Expand All @@ -22,10 +22,9 @@ services:
ports:
- 8081:8081
environment:
#ME_CONFIG_MONGODB_ADMINUSERNAME: root
#ME_CONFIG_MONGODB_ADMINPASSWORD: example
#ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
ME_CONFIG_MONGODB_URL: mongodb://mongo:27017/
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: Qwerty
ME_CONFIG_MONGODB_URL: mongodb://root:Qwerty@mongo:27017/
ME_CONFIG_BASICAUTH: false
networks:
- webnet
Expand Down
19 changes: 19 additions & 0 deletions docker/docker-compose-rethinkdb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
rethinkdb:
image: rethinkdb:latest
restart: "no"
ports:
- "8080:8080"
- "28015:28015"
- "29015:29015"
volumes:
- "rethinkdb:/data"
networks:
- webnet

volumes:
rethinkdb:
driver: local

networks:
webnet:
4 changes: 4 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 8.2.1

* Updated error handling

## 8.2.0

* Require Dart >= 3.3
Expand Down
10 changes: 9 additions & 1 deletion packages/client/lib/base_angel_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ abstract class BaseAngelClient extends Angel {
} on AngelHttpException {
rethrow;
} catch (e, st) {
_log.severe('Authentication failed');
_log.severe(st);
throw failure(response, error: e, stack: st);
}
}
Expand Down Expand Up @@ -202,6 +202,8 @@ abstract class BaseAngelClient extends Angel {
}

class BaseAngelService<Id, Data> extends Service<Id, Data?> {
final _log = Logger('BaseAngelService');

@override
final BaseAngelClient app;
final Uri baseUrl;
Expand Down Expand Up @@ -294,6 +296,7 @@ class BaseAngelService<Id, Data> extends Service<Id, Data?> {
if (_onIndexed.hasListener) {
_onIndexed.addError(e, st);
} else {
_log.severe(st);
throw failure(response, error: e, stack: st);
}
}
Expand Down Expand Up @@ -327,6 +330,7 @@ class BaseAngelService<Id, Data> extends Service<Id, Data?> {
if (_onRead.hasListener) {
_onRead.addError(e, st);
} else {
_log.severe(st);
throw failure(response, error: e, stack: st);
}
}
Expand Down Expand Up @@ -356,6 +360,7 @@ class BaseAngelService<Id, Data> extends Service<Id, Data?> {
if (_onCreated.hasListener) {
_onCreated.addError(e, st);
} else {
_log.severe(st);
throw failure(response, error: e, stack: st);
}
}
Expand Down Expand Up @@ -388,6 +393,7 @@ class BaseAngelService<Id, Data> extends Service<Id, Data?> {
if (_onModified.hasListener) {
_onModified.addError(e, st);
} else {
_log.severe(st);
throw failure(response, error: e, stack: st);
}
}
Expand Down Expand Up @@ -420,6 +426,7 @@ class BaseAngelService<Id, Data> extends Service<Id, Data?> {
if (_onUpdated.hasListener) {
_onUpdated.addError(e, st);
} else {
_log.severe(st);
throw failure(response, error: e, stack: st);
}
}
Expand Down Expand Up @@ -451,6 +458,7 @@ class BaseAngelService<Id, Data> extends Service<Id, Data?> {
if (_onRemoved.hasListener) {
_onRemoved.addError(e, st);
} else {
_log.severe(st);
throw failure(response, error: e, stack: st);
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/mongo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 8.2.1

* Updated README
* Updated example to use MongoDB authentication

## 8.2.0

* Require Dart >= 3.3
Expand Down
15 changes: 13 additions & 2 deletions packages/mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,22 @@ See the tests for more usage examples.

## **Important Notes**

When running with locally installed instance of MongoDB or docker based MongoDB, the following connection string is not supported by the underlying MongoDB driver yet. Best option at the moment is to run MongoDB with the authentication off or use MongoDB Atlas.
When connecting to a locally installed instance of MongoDB or docker based MongoDB with authentication enabled, the following connection string is not supported yet.

```dart
var db = Db('mongodb://<username>:<password>@localhost:27017/local');
var db = Db('mongodb://<username>:<password>@localhost:27017/testDB');
await db.open();
```

Use the following instead. By default the user access information is stored in `admin` database.

```dart
var db = Db('mongodb://localhost:27017/testDB');
await db.open();
await db.authenticate("<username>", "<password>", authDb: "admin");
```

Where

* `<username>` is MongoDB username
* `<password>` is MongoDB password
3 changes: 2 additions & 1 deletion packages/mongo/example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import 'package:mongo_dart/mongo_dart.dart';

void main() async {
var app = Angel(reflector: MirrorsReflector());
var db = Db('mongodb://root:example@localhost:27017/local');
var db = Db('mongodb://localhost:27017/testDB');
await db.open();
await db.authenticate("root", "Qwerty", authDb: "admin");

var service = app.use('/api/users', MongoService(db.collection('users')));

Expand Down
10 changes: 6 additions & 4 deletions packages/mongo/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: angel3_mongo
version: 8.2.0
description: MongoDB-enabled services for the Angel3 framework. Well-tested.
version: 8.2.1
description: This is MongoDB-enabled service for the Angel3 framework.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/mongo
environment:
sdk: '>=3.3.0 <4.0.0'

dependencies:
angel3_framework: ^8.0.0
angel3_container: ^8.0.0
angel3_framework: ^8.4.0
angel3_container: ^8.2.0
belatuk_json_serializer: ^7.1.0
belatuk_merge_map: ^5.1.0
mongo_dart: ^0.10.3

dev_dependencies:
http: ^1.0.0
test: ^1.24.0
Expand Down
4 changes: 3 additions & 1 deletion packages/mongo/test/generic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {
Angel app;
late AngelHttp transport;
late http.Client client;
var db = Db('mongodb://localhost:27017/testingDB');
var db = Db('mongodb://localhost:27017/testDB');

late DbCollection testData;
String? url;
Expand All @@ -38,6 +38,8 @@ void main() {
transport = AngelHttp(app);
client = http.Client();
await db.open();
await db.authenticate("root", "Qwerty", authDb: "admin");

testData = db.collection('testData');
// Delete anything before we start
await testData.remove(<String, dynamic>{});
Expand Down
89 changes: 89 additions & 0 deletions packages/rethinkdb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# See https://www.dartlang.org/tools/private-files.html

# Files and directories created by pub
.buildlog
.packages
.project
.pub/
build/
**/packages/
.dart_tool

# Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)
*.dart.js
*.part.js
*.js.deps
*.js.map
*.info.json

# Directory created by dartdoc
doc/api/

# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
pubspec.lock
### Dart template
# See https://www.dartlang.org/tools/private-files.html

# Files and directories created by pub

# Files created by dart2js
# (Most Dart developers will use pub build to compile Dart, use/modify these
# rules if you intend to use dart2js directly
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
# differentiate from explicit Javascript files)

# Directory created by dartdoc

# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml

# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

12 changes: 12 additions & 0 deletions packages/rethinkdb/AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Primary Authors
===============

* __[Thomas Hii]([email protected])__

Thomas is the current maintainer of the code base. He has refactored and migrated the
code base to support NNBD.

* __[Tobe O]([email protected])__

Tobe has written much of the original code prior to NNBD migration. He has moved on and
is no longer involved with the project.
35 changes: 35 additions & 0 deletions packages/rethinkdb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Change Log

## 8.0.0

* Require Dart >= 3.3
* Updated `lints` to 4.0.0

## 7.0.0

* Skipped release

## 6.0.0

* Skipped release

## 5.0.0

* Skipped release

## 4.0.0

* Skipped release

## 3.0.0

* Skipped release

## 2.0.0

* Migrated to support Dart >= 2.12 NNBD

## 1.1.0

* Moved to `package:rethinkdb_driver`
* Fixed references to old hooked event names
Loading

0 comments on commit 3f04946

Please sign in to comment.