Progressing investigation in https://github.com/david-martin/CouchbaseTest. WIll update this comment with more info as I go along. The majority of below is based on what I disovered while using the Android SDK.
h2. Licensing of components
* Apache-2.0 - https://github.com/couchbase/couchbase-lite-android * Apache-2.0 - https://github.com/couchbase/couchbase-lite-ios * MIT - https://github.com/couchbase/couchbase-lite-net * Apache-2.0 - https://github.com/couchbase/sync_gateway
More repos: https://github.com/couchbase
Info on differences between 'Enterprise' & 'Community' https://www.couchbase.com/products/editions
h2. Mobile API
API documentation https://developer.couchbase.com/documentation/mobile/1.5/references/couchbase-lite/couchbase-lite/index.html
The API looks to be the same across SDK platforms. A `Manager` is used to create/access a `Database` on device. You can create/modify a `Document` in the `Database`. You can get a `View` of a set of `Documents` based on a `Query`. A `Replication` can be setup to push and pull `Database` changes to the Sync Gateway. An `Authenticator` can be configured for auth when doing replication.
It is possible to save binary data by creating 1 or more `Attachment`s and linking them to a `Document`. https://developer.couchbase.com/documentation/mobile/1.5/guides/couchbase-lite/native-api/attachment/index.html
h2. Mobile platforms
* Android - https://github.com/couchbase/couchbase-lite-android * iOS - https://github.com/couchbase/couchbase-lite-ios * .NET - https://github.com/couchbase/couchbase-lite-net
h2. Syncing mechanism to a remote database & other mobile apps
The `Repliation` class is responsible for replicating/syncing data between a local & remote `Database`. https://developer.couchbase.com/documentation/mobile/1.5/references/couchbase-lite/couchbase-lite/replication/replication/index.html Mobile Apps talk to the Sync Gateway, which notifies any interested connected clients of changes to `Documents`. This is done in realtime i through a `_changes` API that notifies clients of any changes to documents they are interested in . e
For iOS, a websocket is used . Realtime Sync For Android, long polling is used . However, there is an open issue to add websocket support for Android, but this shouldn't be too difficult given there's a reference in iOS. https://github.com/couchbase/couchbase-lite-java-core/issues/493 h2. Offline capability
The Mobile SDKs include/allow access to a lightweight database (sqlite or forestdb). The developer has full access to this database while offline. The database gets 'replicated' to/from the sync gateway by creating a Push & Pull Replication instance.
h2. Conflicts
There's documentation on how to programatically list conflicts and ways to resolve them https://developer.couchbase.com/documentation/mobile/current/guides/sync-gateway/resolving-conflicts/index.html https://developer.couchbase.com/documentation/mobile/current/guides/couchbase-lite/native-api/document/index.html#document-conflict-faq
For the server, it seems possible to have automated timestamp based conflict resolution. https://developer.couchbase.com/documentation/server/current/xdcr/xdcr-timestamp-based-conflict-resolution.html
h2. Authentication & Authorisation (e.g. OIDC integration)
The Sync Gateway has the ability to manage users & permissions.
It is also possible to integrate with an external OIDC provider. https://developer.couchbase.com/documentation/mobile/1.5/guides/authentication/openid/index.html
Couchbase docs has general info on OIDC and examples with cloud providers. As part of investigation, the sample Android App has Keycloak working for authentication https://github.com/david-martin/CouchbaseTest. Also, I got the couchbase Grocery Store example working with Keycloak https://github.com/couchbaselabs/GrocerySync-Android. The main changes required were in the sync gateway config for the keycloak client & validation key/secret. For dynamic authorisation, there is a 'sync function' that can be defined. https://developer.couchbase.com/documentation/mobile/1.5/guides/sync-gateway/sync-function-api-guide/index.html "The sync function is the core API you interact with on Sync Gateway. For simple applications it might be the only server-side code you need to write. For more complex applications it is still a primary touchpoint for managing data routing and access control."
I don't fully understand the scope of what can be done with the sync function. However, there is a tool to help generate a sync function based on defintions for access & validation. https://github.com/Kashoo/synctos
There is also scope for an app server sitting in front of the sync gateway (as a proxy) to provide authentication. More info at https://developer.couchbase.com/documentation/mobile/1.5/guides/authentication/custom-authentication/index.html. Again, I'm not sure how much is possible this way. For example, is it possible to define 'middleware' in your own server that could check keycloak roles of the user to see if they are authorised to access/modify certain data.
(Possibly needs a spike to see whats possible around custom authorisation)
h2. Data Source Integrations (Backend integrations)
There is nothing obvious available or no obvious examples for how to add external data sources that sync/replicate to the couchbase server. However, there are 2 potential ways to do this.
1: Write a custom service that uses one of the couchbase-lite clients (e.g. java, python, ruby). That service could perform the necessary data translation between couchbase server and the external data source.
2: Use JBoss Fuse and Apache Camel (following 1 or more Enterprise Integration Patterns) to connect and translate data between couchbase server & the external data source.
h2. Using with an API Gateway (e.g 3scale)
If using longpolling, there should be no issue having an API Gateway in front of the sync gateway. If using websockets, it should be possible, but would have to be tried out. There is an example of using websockets with apicast here https://github.com/VinayBhalerao/apicast-examples/tree/master/apicast-websockets.
h2. Monitoring/Metris
Couchbase server doesn't seem to have a built in prometheus metrics endpoint. However it does have very detailed statistics monitoring https://developer.couchbase.com/documentation/server/current/monitoring/ui-monitoring-statistics.html. There are also a number of examples of prometheus exporters for couchbase. Here are 2:
* https://pypi.python.org/pypi/prometheus-couchbase-exporter/1.0.0 * https://github.com/Zumata/couchbase_exporter
I haven't tried these out, but I'd imagnine its possible to get hooks into the stats (e.g. disk queues, resources, buckets)
h2. Alerting/Hooks
Couchbase has built in admin alerting. See https://developer.couchbase.com/documentation/server/5.0/settings/configure-alerts.html#topic_yq2_qqn_vs for the full list.
It is possible to define webhooks and 'hook' into the changes feed for specific dbs i.e. define event handlers and filter functions. https://developer.couchbase.com/documentation/mobile/current/guides/sync-gateway/server-integration/index.html This could allow for custom alerting based on user defined events.
h2. Compatibility with Kubernetes/OpenShift
Docker images compatible with OpenShift were created as a result of a partnership with Couchbase. This was demoed in Red Hat Summit 2017. Kubernetes templates are also available from this demo.
* https://www.youtube.com/watch?v=fxox6DD96HQ * https://github.com/couchbase-partners/redhat-openshift * https://github.com/couchbase-partners/couchbase-kubernetes-openshift
I haven't tried this out. However, it might be a good way to proceed i.e. try create an APB that uses these images & templates, and allows couchbase-lite-android to hook up to it.
This could be extended, if successful, to try use the mobile cli & mobile-config.json along with the Aerogear Android Core SDK to hook up automatically to what the APB provisions.
It could be extended further to add authentication to the App leveraging Keycloak. This would involve updating the sync gateway's sync-config.json file to add keycloak client/secret details when keycloak and couchbase are bound. |
|