online training - couchbase mobile 101

55
Couchbase M101: Mobile Architecture Jasdeep Jaitla Technical Evangelist twi8er: @scalabl3 email: [email protected]

Upload: couchbase

Post on 20-Aug-2015

793 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Online Training - Couchbase Mobile 101

Couchbase*M101:**Mobile*Architecture

Jasdeep*Jaitla*Technical)Evangelist

twi8er:)@scalabl3email:)[email protected]

Page 2: Online Training - Couchbase Mobile 101

Architecture*of*Couchbase*Mobile

Page 3: Online Training - Couchbase Mobile 101

JSON*Anywhere

On Mobile Device In Data Center/CloudIn Data Center/Cloud

Page 4: Online Training - Couchbase Mobile 101

JSON*Anywhere

On Mobile Device In Data Center/CloudIn Data Center/Cloud

Page 5: Online Training - Couchbase Mobile 101

JSON*Anywhere

On Mobile Device In Data Center/CloudIn Data Center/Cloud

Page 6: Online Training - Couchbase Mobile 101

JSON*Anywhere

On Mobile Device In Data Center/CloudIn Data Center/Cloud

Page 7: Online Training - Couchbase Mobile 101

TradiAonal*Mobile

ApplicaAon*ServerREST*Services

Page 8: Online Training - Couchbase Mobile 101

TradiAonal*Mobile

ApplicaAon*ServerREST*Services

Page 9: Online Training - Couchbase Mobile 101

TradiAonal*Mobile

ApplicaAon*ServerREST*Services

Construction/Deconstruction of

JSON

RDBMS Style Local Storage

Page 10: Online Training - Couchbase Mobile 101

TradiAonal*Mobile

ApplicaAon*ServerREST*Services

Complex Sync Code

Complex Sync Code While Offline or Cannot Use App

While Offline

Construction/Deconstruction of

JSON

RDBMS Style Local Storage

Page 11: Online Training - Couchbase Mobile 101

TradiAonal*Mobile

ApplicaAon*ServerREST*Services

Complex Sync Code

Complex Sync Code While Offline or Cannot Use App

While Offline

Construction/Deconstruction of

JSON

RDBMS Style Local Storage

Page 12: Online Training - Couchbase Mobile 101

Mobile*DBaaS

DBaaSREST*Services

Page 13: Online Training - Couchbase Mobile 101

Mobile*DBaaS

DBaaSREST*Services

Simple Storage Only

Page 14: Online Training - Couchbase Mobile 101

Mobile*DBaaS

DBaaSREST*Services

Scaling Expensive/Slow

Simple Storage Only

Page 15: Online Training - Couchbase Mobile 101

Mobile*DBaaS

DBaaSREST*Services

Scaling Expensive/Slow

Simple Storage Only

Page 16: Online Training - Couchbase Mobile 101

Mobile*DBaaS

DBaaSREST*Services

RDBMS Style Local Storage

Scaling Expensive/Slow

Simple Storage Only

Page 17: Online Training - Couchbase Mobile 101

Mobile*DBaaS

DBaaSREST*Services

RDBMS Style Local Storage

Complex Sync Code

Scaling Expensive/Slow

Simple Storage Only

Page 18: Online Training - Couchbase Mobile 101

JSON*Anywhere*G*Automated*Sync

Page 19: Online Training - Couchbase Mobile 101

JSON*Anywhere*G*Automated*Sync

Page 20: Online Training - Couchbase Mobile 101

JSON*Anywhere*G*Automated*Sync

Synchronization Automated when Connectivity Present

Page 21: Online Training - Couchbase Mobile 101

Couchbase*Lite

Page 22: Online Training - Couchbase Mobile 101

Couchbase*Lite*

The*only*Na3ve*NoSQL*Database*for*

Mobile*

Page 23: Online Training - Couchbase Mobile 101

Couchbase*LiteThe)only)NoSQL)Database)for)Mobile)Devices

Couchbase*Lite**iOS*

Couchbase*Lite**

Android*

Lite

Features*UltraDlightweight,)secure)JSON)database))NaIve)support)for)iOS,)Android)and)REST/HTML5)

Powerful)conflict)resoluIon)Automated)Sync)

Page 24: Online Training - Couchbase Mobile 101

Couchbase*Lite*Features

• Use*JSON*in*your*Mobile*App*Data*Tier*

• Always*Work*with*Local*Data*on*Device*

• Modify*schema*dynamically,*super*flexible*

• When*Connected:**Create*New*Data*and*Change*Documents,*they*Sync*AutomaAcally*

• When*Not*Connected:*Work*with*solid*local*NoSQL*database*

• Powerful*conflict*resoluAon*features

Page 25: Online Training - Couchbase Mobile 101

Partner*IntegraAons

Adobe*PhoneGap*

!

Appcelerator*Titanium*

!

Xamarin

Page 26: Online Training - Couchbase Mobile 101

PhoneGap)Integra.on)Couchbase*Lite*Plug1in*for*PhoneGap*

•  Support*for*HTML5*developers*•  Develop*once*in*JavaScript*and*deploy*

on*iOS*&*Android*•  Available*on*GitHub,*Cordova*Plugin*

Registry,*and*coming*soon*to*build.phonegap.com*

*

hHps://github.com/couchbaselabs/Couchbase1Lite1PhoneGap1Plugin*

hHp://plugins.cordova.io/#/com.couchbase.lite.phonegap*

Page 27: Online Training - Couchbase Mobile 101

Xamarin'Integra,on'Couchbase*Lite*for*Xamarin*

•  Partnered*to*support*C#*community*•  Available*on*Developer*Center*•  Includes*sample*applica=on*to*help*

developers*get*started*today*

h?p://components.xamarin.com/view/couchbaseElite/*

Page 28: Online Training - Couchbase Mobile 101

Appcelerator*Integra.on*Couchbase*Lite*Titanium*

•  Build*rich*na5ve*apps*for*iOS*&*

Android*using*JavaScript*SDK*

•  Now*available*on*the*Appcelerator*

Marketplace*

hEps://github.com/couchbaselabs/couchbaseIliteI5tanium/*

hEps://marketplace.appcelerator.com/apps/6706?1396013098*

Page 29: Online Training - Couchbase Mobile 101

Couchbase*Sync*Gateway

Page 30: Online Training - Couchbase Mobile 101

What*is*the*Sync*Gateway?

• Sync Operations/Management • User Authentication• User channel configuration• User roles and info (name, email, password)• User enable/disable

Couchbase Sync Gateway is a server side program that sits in front of Couchbase Server to manage sync and sync administration

Page 31: Online Training - Couchbase Mobile 101

Sync*Gateway*Overview

Sync Gateway

Subcomponents Couchbase Smart ClientSync REST API

Page 32: Online Training - Couchbase Mobile 101

Subcomponents*of*Sync*Gateway

Sync Gateway

Authentication

Sync FunctionConflict

Management/Revisions

Couchbase Smart ClientSync REST API

Channel Change Tracking

Page 33: Online Training - Couchbase Mobile 101

The*Sync*FuncAon

function(doc,+oldDoc)+{+!

}

Sync Function

Page 34: Online Training - Couchbase Mobile 101

The*Sync*FuncAon

function(doc,+oldDoc)+{+!

}

json doc

Sync Function

Page 35: Online Training - Couchbase Mobile 101

The*Sync*FuncAon

function(doc,+oldDoc)+{+!

}

json doc previous revision, if any

Sync Function

Page 36: Online Training - Couchbase Mobile 101

The*Sync*FuncAon• Defined*in*the*Sync*Gateway*Launch*ConfiguraAon*

• Processes*Documents*and*Sync*FuncAons*Calls*

• Creates*associaAons*between*Documents,*Channels,*Users*and*Roles*

!

• Sync*FuncAons*Calls:*• channel*(channels)**

• access*(usersGroles,*channels)*

• role*(users,*roles)*

• throw({*type:*“message”})

Page 37: Online Training - Couchbase Mobile 101

Sync Function

channel()Associate)JSON)Document)with)a)Channel

function(doc,+oldDoc)+{+channel+(doc.channel_name)+

}

• Channel*Names*are*strings*(i.e.*“food”,*“chatG12939”)*

• Associate*this*Document*to*Channel*or*Array*of*Channels*

• Overwrites*previous*associaAons,*can*change*channels

Page 38: Online Training - Couchbase Mobile 101

Sync Function

channel()Associate)JSON)Document)with)a)Channel

function(doc,+oldDoc)+{+channel+(doc.channel_name)+

}associates this doc

with channel

• Channel*Names*are*strings*(i.e.*“food”,*“chatG12939”)*

• Associate*this*Document*to*Channel*or*Array*of*Channels*

• Overwrites*previous*associaAons,*can*change*channels

Page 39: Online Training - Couchbase Mobile 101

channel()

• Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users*

• Users*are*associated*with*Channels*

• Users*are*associated*with*Roles**

• Roles*are*associated*with*Channels*

• Channels*are*defined*as*JSON*strings*or*array*of*strings*within*the*JSON*Document

Page 40: Online Training - Couchbase Mobile 101

channel()

Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users

User*A

User*B

User*C

JSONdoc.channels*:*“food”

JSONdoc.channels*:*[*“food”,*“sports”*]

JSONdoc.channels*:*[*“sports”,*“travel”*]

channels:*food

channels:*sports

channels:*food,*travel

User*D*creates*Content*

with*Channel*associaAonThese*Users*Subscribed**

to*Content*Channels

Page 41: Online Training - Couchbase Mobile 101

channel()

Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users

User*A

User*B

User*C

JSONdoc.channels*:*“food”

JSONdoc.channels*:*[*“food”,*“sports”*]

JSONdoc.channels*:*[*“sports”,*“travel”*]

channels:*food

channels:*sports

channels:*food,*travel

User*D*creates*Content*

with*Channel*associaAonThese*Users*Subscribed**

to*Content*Channels

Page 42: Online Training - Couchbase Mobile 101

channel()

Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users

User*A

User*B

User*C

JSONdoc.channels*:*“food”

JSONdoc.channels*:*[*“food”,*“sports”*]

JSONdoc.channels*:*[*“sports”,*“travel”*]

channels:*food

channels:*sports

channels:*food,*travel

User*D*creates*Content*

with*Channel*associaAonThese*Users*Subscribed**

to*Content*Channels

Page 43: Online Training - Couchbase Mobile 101

channel()

Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users

User*A

User*B

User*C

JSONdoc.channels*:*“food”

JSONdoc.channels*:*[*“food”,*“sports”*]

JSONdoc.channels*:*[*“sports”,*“travel”*]

channels:*food

channels:*sports

channels:*food,*travel

User*D*creates*Content*

with*Channel*associaAonThese*Users*Subscribed**

to*Content*Channels

Page 44: Online Training - Couchbase Mobile 101

channel()

Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users

User*A

User*B

User*C

JSONdoc.channels*:*“food”

JSONdoc.channels*:*[*“food”,*“sports”*]

JSONdoc.channels*:*[*“sports”,*“travel”*]

channels:*food

channels:*sports

channels:*food,*travel

User*D*creates*Content*

with*Channel*associaAonThese*Users*Subscribed**

to*Content*Channels

Page 45: Online Training - Couchbase Mobile 101

channel()

Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users

User*A

User*B

User*C

JSONdoc.channels*:*“food”

JSONdoc.channels*:*[*“food”,*“sports”*]

JSONdoc.channels*:*[*“sports”,*“travel”*]

channels:*food

channels:*sports

channels:*food,*travel

User*D*creates*Content*

with*Channel*associaAonThese*Users*Subscribed**

to*Content*Channels

Page 46: Online Training - Couchbase Mobile 101

channel()

Channels*organize*what*JSON*Documents*are*synchronized*down*to*which*Users

User*A

User*B

User*C

JSONdoc.channels*:*“food”

JSONdoc.channels*:*[*“food”,*“sports”*]

JSONdoc.channels*:*[*“sports”,*“travel”*]

channels:*food

channels:*sports

channels:*food,*travel

User*D*creates*Content*

with*Channel*associaAonThese*Users*Subscribed**

to*Content*Channels

Page 47: Online Training - Couchbase Mobile 101

access()Grants)access)to)channels)

• Associate*a*User,*or*Array*of*Users*to*one*or*more*Channels*

• Associate*a*Role*(group*of*Users)*to*one*or*more*Channels

Sync Function

function(doc,+oldDoc)+{+access+(doc.friends,+doc.channels)+

}

Page 48: Online Training - Couchbase Mobile 101

access()Grants)access)to)channels)

• Associate*a*User,*or*Array*of*Users*to*one*or*more*Channels*

• Associate*a*Role*(group*of*Users)*to*one*or*more*Channels

Sync Function

function(doc,+oldDoc)+{+access+(doc.friends,+doc.channels)+

}associates users/roles

with channel(s)

Page 49: Online Training - Couchbase Mobile 101

role()grants)users)a)role

• Associate*a*User,*or*Array*of*Users*to*one*or*more*Roles*

• Roles*can*give*enAre*groups*of*Users*access*to*Channels

Sync Function

function(doc,+oldDoc)+{+role+(doc.friends,+roles)+

}

Page 50: Online Training - Couchbase Mobile 101

role()grants)users)a)role

• Associate*a*User,*or*Array*of*Users*to*one*or*more*Roles*

• Roles*can*give*enAre*groups*of*Users*access*to*Channels

Sync Function

function(doc,+oldDoc)+{+role+(doc.friends,+roles)+

}associates user(s)

with role(s)

Page 51: Online Training - Couchbase Mobile 101

throw()validate)documents,)prevent)syncing/modificaIons

• ValidaAon*of*document*data*and*associaAons*

• ValidaAon*of*authenAcaAon

Sync Function

function(doc,+oldDoc)+{+throw+({+type:+“message”})+

}

Page 52: Online Training - Couchbase Mobile 101

throw()validate)documents,)prevent)syncing/modificaIons

• ValidaAon*of*document*data*and*associaAons*

• ValidaAon*of*authenAcaAon

Sync Function

function(doc,+oldDoc)+{+throw+({+type:+“message”})+

}invalidates this

document

Page 53: Online Training - Couchbase Mobile 101

Collaborate*with*Channels

• For*each*document,*you*specify*a*set*of*channels*it*belongs*to*

• For*each*user*or*device,*you*control*which*channels*they*can*access*

• Replicate*only*a*subset*of*documents*down*to*the*device*

• UserDdefined)filter)funcIons))• Simply)lets)you)know)whether)a)document)should)be)replicated)• And*you*can*authenAcate*users*with*Facebook*

and*Persona

Page 54: Online Training - Couchbase Mobile 101

DEMO

Page 55: Online Training - Couchbase Mobile 101

Q*&*A