• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
루비가 얼랭에 빠진 날
 

루비가 얼랭에 빠진 날

on

  • 982 views

2008.5 제5회 루비세미나 발표

2008.5 제5회 루비세미나 발표

Statistics

Views

Total Views
982
Views on SlideShare
982
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    루비가 얼랭에 빠진 날 루비가 얼랭에 빠진 날 Presentation Transcript

    • 루비 가 얼랭 에 빠진 날 http ://thinkr.egloos.com [email_address] 제 6 회 루비세미나 (2008.6.28)
    • Concurrency -oriented Programming
    • How Erlang programs work?
      • 많은 프로세스들로 구성
        • 운영체제 독립적인 경량 (light-weight) 프로세스
        • 유일한 식별자 (Pid)
        • 많은 프로세스를 동시 처리 (100,000 개 이상 )
      • 프로세스들 간에 서로 메시지를 주고 받음
        • 비동기적 메시지 전달 메커니즘
      • 프로세스는 서로 연결 (link) 될 수 있음
        • 연결된 프로세스가 죽으면 다른 프로세스가 통보받음
        • 수퍼바이저 / 워커 모델 구성
    • A Stateless Server Process -module(demo2). -compile(export_all). run() -> Pid = spawn(fun echo/0), Pid ! {self(), hello, 42}, receive {Pid, reply, 42} -> Pid ! stop end. echo() -> receive {From, hello, Val} -> From ! {self(), reply, Val}, echo(); % loop! stop -> io:format("Done!~n", []), ok end. P1 P2 {P1, hello, 42} {P2, reply, 42} Client Server stop
    • Benefits of COP
      • 성능 (Performance)
        • 분산 병렬 처리
        • Multi-core Support
      • 가용성 (Reliability)
        • 무정지 (fault-tolerent)
        • Hot code swapping
      • 확장성 (Scalability)
    • generic_server OTP gen_server 비헤비어
    • Apache vs. Yaws * http://www.sics.se /~joe/apachevsyaws.html
    • RE presentational S tate T ransfer
    • RESTful URL ( Rails )
      • GET /posts index
      • GET /posts/1 show
      • GET /posts/new new
      • GET /posts/1/edit edit
      • POST /posts create
      • PUT /posts/1 update
      • DELETE /posts/1 destroy
    • respond_to :wow! # POST /posts # POST /posts.xml def create @post = Post.new(params[:post]) respond_to do |format| if @post.save flash[:notice] = 'Post was successfully created.' format.html { redirect_to(@post) } format.xml { render :xml => @post, :status => :created, :location => @post } else format.html { render :action => "new" } format.xml { render :xml => @post.errors, :status => :unprocessable_entity } end end end
    • GoogleTrends “ ruby on rails ” 1.0 1.2 2.0 resource 도입 from MVC to REST
    • The RADAR Architecture * RESTful Application, Dumb-Ass Recipient ( http://pragdave.pragprog.com/pragdave/2007/03/the_radar_archi.html )
    • Time to Relax…
    • CouchDB
      • 문서 (document) 기반 데이터베이스 서버 .
        • Aaccessible via a RESTful JSON API
        • Views (incremental map/reduce)
        • Schema-Free
        • Distributed, robust architecture
        • Written in Erlang
        • Apache Incubating (alpha 0.8 release)
    • SQL vs. CouchDB * http ://www.zefhemel.com/archives/2008/03/11/sittin-on-the-couchdb Static queries of dynamic schemas Dynamic queries of static schemas Must know only document name Must know schema to read/write a complete object Denormalized. Docs usually self contained. Data often duplicated. Normalized. Objects spread across tables. Duplication reduced. Collection of named documents with varying structure Uniform tables of data Dynamic, implicit schema Predefined, explicit schema CouchDB SQL
    • Document = JSON Object { "_id":"discussion_tables", "_rev":"D1C946B7", "Subject":"I like Planktion", "Author":"Rusty", "PostedDate":"2006-08-15T17:30:12-04:00", "Tags":["plankton", "baseball", "decisions"], "Body":"I decided today that I don't like baseball. I like plankton." }
    • Some CouchDB REST APIs
      • Dababase API
        • GET /_all_dbs 모든 DB
        • PUT /database/ 새 DB 생성
        • DELETE /database/
      • Document API
        • GET /database/doc_id
        • POST /database/ 또는 PUT /database/doc_id
        • PUT /database/doc_id (with ‘_rev’ property)
        • DELETE /database/dic_id?rev=xxx
      • View API
        • GET /database/_view/view_name/func_name
    • Accessing CouchDB with Ruby
      • 범용
        • ActiveResource
        • REST Client
      • CouchDB 전용
        • CouchObject
        • Ruby-CouchDB
        • ActiveCouch
        • Couchrest
    • DEMO
    • Admin Interface
    • Ruby View
    • Extending ARes class CouchResource < ActiveResource::Base class << self def element_path(id, prefix_options = {}, query_options = nil) &quot;#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}&quot; def collection_path(prefix_options = {}, query_options = nil) &quot;#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}&quot; def instantiate_collection(collection, prefix_options = {}) collection = collection.fetch(&quot;rows&quot;) if collection.kind_of? Hash def instantiate_record(record, prefix_options = {}) record = record.fetch(&quot;value&quot;) if record.has_key? &quot;value“ def find_view(view_name, func_name) find(:all, :from => &quot;/#{element_name}/_view/#{view_name}/#{func_name}&quot;) end
    • Mywiki Resource class Mywiki < CouchResource self.site = &quot;http://localhost:5984&quot; self.format = :json self.collection_name = 'mywiki' # used as a database name self.primary_key = '_id' end
    • Console Result
    • Finish!!