Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Rename gem #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2018 OurPC contributors
Copyright (c) 2018 ArrPC contributors

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
12 changes: 6 additions & 6 deletions README.md
@@ -1,8 +1,8 @@
# OurPC
# ArrPC

OurPC is an experimental implementation of a gRPC client and server.
ArrPC is an experimental implementation of a gRPC client and server.

OurPC uses nghttp2, Ruby IO objects, and Protobuf as the building blocks for implementing a gRPC server and client. The core of OurPC simply sets the right headers (including the Protobuf buffer prefix), and delegates to either the server code or the client code depending on the context.
ArrPC uses nghttp2, Ruby IO objects, and Protobuf as the building blocks for implementing a gRPC server and client. The core of ArrPC simply sets the right headers (including the Protobuf buffer prefix), and delegates to either the server code or the client code depending on the context.

## Features

Expand All @@ -16,20 +16,20 @@ OurPC uses nghttp2, Ruby IO objects, and Protobuf as the building blocks for imp

* Doesn't support streaming yet.

* OurPC doesn't have many tests (it's an experiment!)
* ArrPC doesn't have many tests (it's an experiment!)

## Fun times!

Try this! In one terminal:

```
$ rake server
$ rake ship
```

In a different terminal:

```
$ rake client
$ rake matey
```

Neat!
6 changes: 3 additions & 3 deletions Rakefile
Expand Up @@ -30,11 +30,11 @@ end

task "examples/lib/helloworld_pb.rb"

task :server => ["examples/lib/helloworld_pb.rb", :deps] do
sh "ruby -I lib:examples/lib hello_world_server.rb"
task :ship => ["examples/lib/helloworld_pb.rb", :deps] do
sh "ruby -I lib:examples/lib hello_world_ship.rb"
end

task :client => ["examples/lib/helloworld_pb.rb", :deps] do
task :matey => ["examples/lib/helloworld_pb.rb", :deps] do
sh "ruby -I lib:examples/lib hello_world.rb"
end

Expand Down
6 changes: 3 additions & 3 deletions hello_world.rb
Expand Up @@ -2,18 +2,18 @@

## This part is equivalent the generated RPC stubs from the gRPC gem

require "our_pc/client"
require "arr_pc/matey"
require "helloworld_pb"

include Helloworld

class HelloWorld < OurPC::Client
class HelloWorld < ArrPC::Matey
service "helloworld.Greeter" do |rpc|
rpc.method "SayHello", HelloRequest, HelloReply
end
end

# This is the client part. The stub part in OurPC looks nice so I didn't
# This is the client part. The stub part in ArrPC looks nice so I didn't
# bother putting it in a different file.

client = HelloWorld.new "localhost:50051"
Expand Down
6 changes: 3 additions & 3 deletions hello_world_server.rb → hello_world_ship.rb
@@ -1,10 +1,10 @@
require 'our_pc/server'
require 'arr_pc/ship'
require 'socket'
require "helloworld_pb"

include Helloworld

class HelloWorldServer < OurPC::Server
class HelloWorldShip < ArrPC::Ship
service "helloworld.Greeter" do |rpc|
rpc.method "SayHello", HelloRequest, HelloReply do |req|
HelloReply.new(message: "Hello #{req.name}")
Expand All @@ -18,7 +18,7 @@ class HelloWorldServer < OurPC::Server
conn = server.accept # Wait for a client to connect
conn.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
puts "Got a client"
session = HelloWorldServer.new conn
session = HelloWorldShip.new conn
session.run
puts "finished"
end
8 changes: 4 additions & 4 deletions lib/our_pc/client.rb → lib/arr_pc/matey.rb
@@ -1,9 +1,9 @@
require "socket"
require "io/wait"
require "our_pc/session"
require "arr_pc/voyage"

module OurPC
class Client
module ArrPC
class Matey
def initialize address
@host, @port = address.split ':'
@scheme = 'http'
Expand All @@ -13,7 +13,7 @@ def initialize address

def connect
@socket = make_connection
@session = Session.new @socket
@session = Voyage.new @socket
@session.submit_settings []
end

Expand Down
8 changes: 4 additions & 4 deletions lib/our_pc/server.rb → lib/arr_pc/ship.rb
@@ -1,11 +1,11 @@
require "socket"
require "io/wait"
require "our_pc/session"
require "arr_pc/voyage"

module OurPC
class Server
module ArrPC
class Ship
def initialize socket
@session = Session.new socket, self
@session = Voyage.new socket, self
@session.submit_settings [
[DS9::Settings::MAX_CONCURRENT_STREAMS, 100],
]
Expand Down
12 changes: 6 additions & 6 deletions lib/our_pc/session.rb → lib/arr_pc/voyage.rb
@@ -1,6 +1,6 @@
require "ds9"

module OurPC
module ArrPC
module IOEvents
def initialize reader, writer
super()
Expand Down Expand Up @@ -48,8 +48,8 @@ def done?
end
end

class Client
class Session < ::DS9::Client
class Matey
class Voyage < ::DS9::Client
include IOEvents

def initialize sock
Expand Down Expand Up @@ -102,7 +102,7 @@ def done?
end
end

class Server
class Ship
class Request
attr_accessor :protobuf

Expand All @@ -122,7 +122,7 @@ def [] k

def << x
if @in_flight
raise "no implemented yet"
raise "not implemented yet"
else
_, len, buf = x.unpack('CNa*')

Expand All @@ -144,7 +144,7 @@ def path
end
end

class Session < DS9::Server
class Voyage < DS9::Server
include IOEvents

def initialize sock, handler
Expand Down
6 changes: 3 additions & 3 deletions test/client_test.rb
@@ -1,9 +1,9 @@
require "helper"
require 'our_pc/server'
require 'arr_pc/ship'
require "google/protobuf"

class DSLTest < OurPC::Test
class HelloWorldService < OurPC::Server
class DSLTest < ArrPC::Test
class HelloWorldShip < ArrPC::Ship
end

def test_lol
Expand Down
2 changes: 1 addition & 1 deletion test/dsl_test.rb
@@ -1,6 +1,6 @@
require "helper"

class DSLTest < OurPC::Test
class DSLTest < ArrPC::Test
def test_omg
assert true
end
Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
@@ -1,6 +1,6 @@
require "minitest/autorun"

module OurPC
module ArrPC
class Test < Minitest::Test
end
end