Channel APIï¼Matcher APIã§ã¤ããã¤ãã³ãé§åWebã¢ããª
ããã¯appengine ja night #12ã®ãã¬ã¼ã³è³æã§ãã
Channel APIã¨ã¯
Channel APIã¯ãApp Engineã§åä½ããããã·ã¥éä¿¡ãµã¼ãã¹ã§ãã詳ããã¯ãã¡ãï¼
Matcher APIã¨ã¯
Matcher APIã¨ã¯ããã¹ã±ã¼ã©ãã«ãªãªã¢ã«ã¿ã¤ã ãããã³ã°ãµã¼ãã¹ãã§ãã
- ãããã³ã°ã®æ¡ä»¶ãç¬èªã®ã¯ã¨ãªæ§æã§è¨è¿°ãã¦ç»é²
- ã¨ã³ãã£ãã£ãdictã®å 容ãæ¡ä»¶ã«åè´ããã¨ãã¿ã¹ã¯ã§éç¥
- æ°åãæ°ä¸ä»¶ã®æ¡ä»¶ãæ°ç§ã§ãã§ãã¯ãéç¥ã§ãã¾ã
Matcher APIã¨ã¯
ç°¡åã«è¨ãã¨ãã
DB/Datastoreã®ã¯ã¨ãªã¯ãéå»ã«å¯¾ããã¯ã¨ãªã
Matcherã®ã¯ã¨ãªã¯ãæªæ¥ã«å¯¾ããã¯ã¨ãªã
ä¾ãã°ãããªdb.Modelãæ³å®
class Person(db.Model):
name = db.StringProperty()
birth = db.IntegerProperty()
height_meters = db.FloatProperty()
æ¡ä»¶ãç»é²
matcher.subscribe(Person, âname: smith OR name:schmidtâ, âsmithâ)
matcher.subscribe(Person, âbirth < 1900â, âoldâ)
matcher.subscribe(Person, âheight_meters > 2.0â, âtallâ)
matcher.subscribe(Person, âbirth > 1945 AND birth < 1965â, âboomerâ)
- åã ã®ç»é²ã«IDãæ¯ãï¼sub_idï¼
personãæ´æ°ãããããmatch()
person = MatcherDocument()
person.name = âsmithâ
person.height_meters = 1.5
matcher.match(person)
ã¿ã¹ã¯ã§éç¥ããã
- /_ah/matcher ãå¼ã°ãã
- åè´ããsub_idã®ãªã¹ãã渡ããã
- ãã¾ã大ããªãã¼ã¿ã¯åãåããªã
- Memcacheãªã©ãä½µç¨
dictã§ãOK
person = { 'name': 'Andrew Smith', 'citizenship': 'Brazil', 'birth': 1975, 'height_meters': 1.54, }
- Datastoreã«ã¯éä¾å
dictã®å ´åãäºåã«ã¹ãã¼ããå®ç¾©
PersonSchema = {
str: ['name', 'citizenship'],
int: ['birth']
float: [height_meters']
}
Matcherã®ã¯ã¨ãªè¨èª
ããã¹ãã®é¨åä¸è´
field_text_a:horse
field_text_a:"horse riding"
æ°å¤
> >=, =, <= and <
è«çæ¼ç®
AND, OR, NOT
Matcherã®ã¯ã¨ãªä¾
- ã«ãã³ã§æ¬ã£ã¦ãã¹ããã§ãã
field_int32_a > 20 AND field_int32_b = 10
(field_int32_a > 20 AND field_int32_b = 10) OR field_text_a:fox
Matcherã®APIãsubscribeã
Matcherã«æ¡ä»¶ãç»é²ãã¾ãã
matcher.subscribe(document_class,
query,
sub_id,
schema=None,
topic=None,
lease_duration_sec=DEFAULT_LEASE_DURATION_SEC)
- query: ã¯ã¨ãªãè¨è¿°
- sub_id: åã ã®ãµãã¹ã¯ãªãã·ã§ã³ã«ä»ããID
- schema: dict/Entityã®ã¨ã使ç¨
- topic: åå空éãåãããã
- lease_duration_sec: ãµãã¹ã¯ãªãã·ã§ã³ã®æå¹æé
Matcherã®APIãunsubscribeã
Matcherã®æ¡ä»¶ãåé¤ãã¾ãã
matcher.unsubscribe(document_class,
sub_id,
topic=None)
Matcherã®APIãmatchã
å¼æ°ã®ããã¥ã¡ã³ãã¨ãã¹ã¦ã®æ¡ä»¶ã¨æ¯è¼ãã¾ãã
matcher.match(document,
topic=None,
result_key=None,
result_relative_url='/_ah/matcher',
result_task_queue='default',
result_batch_size=DEFAULT_RESULT_BATCH_SIZE,
result_return_document=True)
Matcherã®APIãmatchã
- result_key: ããã¥ã¡ã³ãã«å²ãå½ã¦ããã¼
- result_batch_size: åã ã®ã¿ã¹ã¯ã«æ¸¡ãsub_idã®æ大æ°
- result_return_document: ã¿ã¹ã¯ã«ããã¥ã¡ã³ãã渡ããã©ãã
Matcherã®APIãlist_subscriptionsã
ãµãã¹ã¯ãªãã·ã§ã³ã®ä¸è¦§ãè¿ãã¾ãã
list_subscriptions(document_class,
sub_id_start="",
topic=None,
max_results=1000,
expires_before=None)
- ãµãã¹ã¯ãªãã·ã§ã³ã®ç¶æ
OK -- ã¢ã¯ãã£ã
PENDING -- ã¾ã ã¢ã¯ãã£ãã§ã¯ãªãç¶æ
ERROR -- ã¨ã©ã¼
Matcherã®ã¿ã¹ã¯
ã¿ã¹ã¯/_ah/matcherã§ã¯ããããçµæãå¦çãã¾ãã
次ã®ãã©ã¡ã¼ã¿ã渡ããã¾ãã
- id: ãµãã¹ã¯ãªãã·ã§ã³ã®IDã®ãªã¹ã
- results_count: ãµãã¹ã¯ãªãã·ã§ã³å ¨ä½ã®ãããæ°
- results_offset: ãã®ã¿ã¹ã¯ã®result_countå ã®ãªãã»ãã
- topic: ãããã¯å
- matcher.get_document(self.request): ããã¥ã¡ã³ããåå¾
Matcherã®ä½¿ãé
Twitterã®ãã¼ã¯ã¼ãæ¤ç´¢ã®ã¹ããªã¼ãã³ã°
Google Instant/Percolator
- ï¼ã¹ãã¢ãããã·ã¼ã¸ã£ï¼
ååã»æ ªä¾¡çã®ã¢ã©ã¼ã
pub/subã¡ãã»ã¼ã¸ã³ã°ãCEPï¼å¾è¿°ï¼
ï¼ä½¿ãéãæ³åã¤ããªãã®ãé¢ç½ã
jsonengineã§ã®CQL対å¿
CQLï¼Continuous Query Language
/_je/myDoc?name.eq.kaz
Channel APIçµç±ã§çµæãè¿ã
ã¯ã¨ãªæ¡ä»¶ã«åè´ããdocæ´æ°ãç¶ç¶çã«éç¥
âã¹ããªã¼ã æ¤ç´¢ã¨ãç°¡åã«å®è£
å¯è½
ã¤ãã³ããã¹ããªã¼ã ãCEP
ã¹ããªã¼ã ï¼ã¤ãã³ãé§åãªã¯ã©ã¦ãæè¡
- Yahoo S4
- Google waveã¨OT
- Google InstantãPercolatorã¨ObserverãInternet DOM
- node.jsãtornado
- Adobe LCDS, remote data binding
CEPã£ã¦ä½ã
Complex Event Processing
ãªã¯ã¨ã¹ãï¼ããããèµ·ãã¦ã»ãããã¨ã®è¦æ±
ã¤ãã³ãï¼ãã§ã«èµ·ãããã¨ã®éç¥
- ï¼ã¡ãã»ã¼ã¸ã¨ã¯ã¡ãã£ã¨éãã¿ããï¼
ã¤ãã³ãå¦çã¨ã¼ã¸ã§ã³ãã®éåä½ã§ã¢ããªãæ§ç¯
CEPãããã
ã¹ããªã¼ã ï¼ã¤ãã³ãé§åãªæ¸ç±
- Event processing in action
- Distributed event-based systems