The dRuby Book doc

266 306 0
The dRuby Book doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... class contains the puts method that we’ll make available to the client 3 On line 12, we start the dRuby service We provide the URI (which the user passes in on the command line) The URL is the address the client uses to connect to the server We also provide the object that will be tied to the URI You’ll find out more about the URI in The dRuby URI, Services, and Clients, on page 7 4 A dRuby service... concept of dRuby dRuby lets you pass normal Ruby objects and call their methods across processes and networks seamlessly With dRuby, you’ll experience the world of distributed computing as a natural extension of Ruby The most widely used distributed system in the world is probably the Web It’s one of the most successful ways to distribute documents around the world —and dRuby s history is related to the Web... [Terminal 1] % ruby puts00.rb druby: //localhost:12345 druby: //localhost:12345 The server process waits for the request to arrive Make sure that the server doesn’t terminate, even after it prints out the URI of the service Using the Service from irb The next step is to write the client Rather than writing a program file, we’ll just use irb Open another terminal (terminal 2) and type the following: # [Terminal... try other characters Make sure you observe the server terminal while you are typing in irb Back in irb on terminal 2, let’s call the server again # [Terminal 2] irb(main):004:0> there.puts('R is for Ruby.') => nil You should see the second message appear on terminal 1 The there variable in the client refers to the Puts service object By sending the puts method to the there variable, you invoke the puts... is the third edition of The dRuby Book (the previous two editions were in Japanese) For this edition, I’ve rewritten the book to cover the latest dRuby information and new libraries If you are looking for theoretical definitions of distributed objects or detailed comparisons of various systems, look elsewhere! This book is full of hands-on exercises and interesting code examples I hope you put this book. .. object in the variable there Now we can use this dRuby object to access methods on the server It’s as if the client has access to the Puts object we created on the server report erratum • discuss Hello, World •5 OS X and readline If you use OS X and have problems getting a prompt after there = DRbObject.new_with_uri(uri), then it may be a problem with the readline library To work around the problem,... to submit errata for the book and to participate in its discussion forum You’ll also find the source code for all the projects we build You can click the box before the code excerpts to download that snippet directly Let’s get started! 1 http:/ pragprog.com/titles/sidruby / report erratum • discuss Part I Introducing dRuby Welcome to the world of dRuby In this part, you’ll learn dRuby s basic concepts... Hello, dRuby Puts puts('Hello, World.') puts() puts00.rb Client irb Figure 1—Puts server and irb client dRuby raised an exception DRbConnError means that there is a communication error between dRuby processes The client failed to invoke the method because the server is stopped Let’s start the server again in terminal 1 # [Terminal 1] % ruby puts00.rb druby: //localhost:12345 druby: //localhost:12345 Try there.puts... a simple dRuby example, and we’ve seen how easy it is to write a client-server model script It’s time to go a little further The dRuby URI, Services, and Clients In the previous example, we used druby: //localhost:12345 as a URI, but we haven’t seen what this actually means In this section, we’ll learn about the relationship between the dRuby URI and the URI specified in DRb.start_service A dRuby URI... we were able to run the clients on the same machine as the server This time, we’ve used an externally accessible name, so you can try running a client on a separate machine that is networked with the server Just specify the URI of the server, the same way you did when running the client locally 1.3 Moving Ahead In this chapter, we learned the following: • We can use dRuby out of the box, because it . About The dRuby Book The dRuby Book is a fantastic introduction to distributed programming in Ruby for all levels of users. The book covers all aspects of dRuby, . to the client. 3. On line 12, we start the dRuby service. We provide the URI (which the user passes in on the command line). The URL is the address the

Ngày đăng: 15/03/2014, 02:20

Mục lục

  • Cover

  • Table of Contents

  • Foreword

  • Acknowledgments

    • For the Japanese Edition

    • For the English Edition

    • Preface

      • Who This Book Is For

      • Environment

      • What's in This Book

      • Conventions Used in This Book

      • Part I—Introducing dRuby

        • 1. Hello, dRuby

          • Hello, World

          • Building the Reminder Application

          • Moving Ahead

          • 2. Architectures of Distributed Systems

            • Understanding Distributed Object Systems

            • Design Principles of dRuby

            • dRuby in the Real World

            • Moving Ahead

            • Part II—Understanding dRuby

              • 3. Integrating dRuby with eRuby

                • Generating Templates with ERB

                • Integrating WEBrick::CGI and ERB with dRuby

                • Putting Them Together

                • Adding an Error Page

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan