souls 0.8.3 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,75 +0,0 @@
1
- # gRPC Ruby Server
2
- gRPC Ruby Server Boilerplate
3
-
4
- <p align="center">
5
-
6
- <a aria-label="Ruby logo" href="https://el-soul.com">
7
- <img src="https://badgen.net/badge/icon/Made%20by%20ELSOUL?icon=ruby&label&color=black&labelColor=black">
8
- </a>
9
- <br/>
10
- </p>
11
-
12
- ## Installation
13
-
14
- git clone
15
-
16
- ```
17
- git clone git@github.com:elsoul/grpc-ruby-server.git
18
- cd grpc-ruby-server
19
- bundle install
20
- ```
21
-
22
-
23
-
24
- ## Usage
25
-
26
- Check Rakefile to see what command is available
27
-
28
- ```ruby
29
- rake -T
30
- ```
31
-
32
-
33
- # Run Server on local
34
-
35
- ```ruby
36
- rake run_server
37
- ```
38
-
39
- # Run Server with Docker
40
-
41
- ```ruby
42
- rake run_test
43
- ```
44
-
45
- # Run Client to check response
46
-
47
- ```ruby
48
- rake run_client
49
- ```
50
-
51
- Then you will get response below;
52
-
53
- ```
54
- "Greeting: Hello world"
55
- "Greeting: Hello again, world"
56
- ```
57
-
58
-
59
- ## Development
60
-
61
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
-
63
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/grpc-ruby-server).
64
-
65
- ## Contributing
66
-
67
- Bug reports and pull requests are welcome on GitHub at https://github.com/elsoul/grpc-ruby-server. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
68
-
69
- ## License
70
-
71
- The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
72
-
73
- ## Code of Conduct
74
-
75
- Everyone interacting in the HotelPrice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elsoul/grpc-ruby-server/blob/master/CODE_OF_CONDUCT.md).
@@ -1,34 +0,0 @@
1
- require "yaml"
2
- require "erb"
3
- require "logger"
4
-
5
- desc "Generate proto files"
6
- task :proto do
7
- system "grpc_tools_ruby_protoc -I ./protos --ruby_out=./app/services --grpc_out=./app/services ./protos/blog.proto"
8
- end
9
-
10
- desc "Run gRPC Server"
11
- task :run_server do
12
- system "ruby grpc_server.rb"
13
- end
14
-
15
- desc "Run gRPC Client"
16
- task :run_client do
17
- system "ruby greeter_client.rb"
18
- end
19
-
20
- desc "Run gRPC Server with Docker"
21
- task :run_test do
22
- system "docker build . -t souls_service:latest"
23
- system "docker rm -f web"
24
- system "docker run --name web -p 50051:50051 souls_service:latest"
25
- end
26
-
27
- desc "Update Google Container Registry"
28
- task :update do
29
- version = ARGV[1]
30
- project_id = "elsoul2"
31
- system("docker build . -t souls_service:#{version}")
32
- system("docker tag souls_service:#{version} asia.gcr.io/#{project_id}/souls_service:#{version}")
33
- system("docker push asia.gcr.io/#{project_id}/souls_service:#{version}")
34
- end
@@ -1,26 +0,0 @@
1
- require "grpc"
2
- require "yaml"
3
- require "erb"
4
- require "logger"
5
- require "zeitwerk"
6
- require "dotenv/load"
7
- require "google/cloud/firestore"
8
- require "./app"
9
-
10
- ENV["SOULS_ENV"] ||= "development"
11
-
12
- # NoSQL Conf
13
- # YAML.safe_load(ERB.new(File.new("./config/mongoid.yml").read).result)
14
-
15
- ## SQL Conf
16
- # db_conf = YAML.safe_load(ERB.new(File.read("./config/database.yml")).result, [], [], true)
17
- # ActiveRecord::Base.establish_connection(db_conf[ENV["RACK_ENV"]])
18
-
19
- loader = Zeitwerk::Loader.new
20
- loader.push_dir("#{Dir.pwd}/app/controllers")
21
- loader.push_dir("#{Dir.pwd}/app/services")
22
- loader.do_not_eager_load("#{Dir.pwd}/app/services")
23
- loader.collapse("#{__dir__}/app/services")
24
- loader.setup
25
-
26
- loader.eager_load
@@ -1,3 +0,0 @@
1
- class ApplicationController < Souls::Blog::Service
2
- include ArticleMethod, HelloMethod
3
- end
@@ -1,60 +0,0 @@
1
- module ArticleMethod
2
- def create_article(grpc_req, _unused_call)
3
- logger = Logger.new(STDOUT)
4
- firestore = Google::Cloud::Firestore.new
5
- article = firestore.col("articles").doc
6
- article.set({})
7
- data = firestore.col("articles").doc(article.document_id)
8
- article_hash = {
9
- id: article.document_id,
10
- user_id: grpc_req.user_id,
11
- title: grpc_req.title,
12
- body: grpc_req.body,
13
- thumnail_url: grpc_req.thumnail_url,
14
- public_date: grpc_req.public_date,
15
- is_public: grpc_req.is_public,
16
- tag: grpc_req.tag.to_a,
17
- created_at: Time.now.utc,
18
- updated_at: Time.now.utc
19
- }
20
- data.update article_hash
21
- res = Souls::CreateArticleReply.new(
22
- { article: article_hash }
23
- )
24
- logger.info res.article
25
- res
26
- rescue StandardError => error
27
- logger.debug error
28
- end
29
-
30
- def get_article(grpc_req, _unused_call)
31
- logger = Logger.new(STDOUT)
32
- article = Article.find(grpc_req.id)
33
- reply = JSON.parse(article.to_json)
34
- reply["created_at"] = article.created_at.to_s
35
- reply["updated_at"] = article.updated_at.to_s
36
- res = Souls::GetArticleReply.new(
37
- { article: Souls::Article.new(reply) }
38
- )
39
- logger.info res.article
40
- res
41
- rescue StandardError => error
42
- logger.debug error
43
- end
44
-
45
- def get_articles
46
- return enum_for(:get_articles) unless block_given?
47
- q = ::Article
48
- limit = 100
49
- q.limit(limit).each do |article|
50
- sleep(rand(0.01..0.3))
51
- Souls::Article.new article.to_proto
52
- end
53
- rescue StandardError => e
54
- fail!(:internal, :unknown, "Unknown error when listing Articles: #{e.message}")
55
- end
56
-
57
- def update_article(grpc_req, _unused_call); end
58
-
59
- def delete_article(grpc_req, _unused_call); end
60
- end
@@ -1,13 +0,0 @@
1
- module HelloMethod
2
- def say_hello(hello_req, _unused_call)
3
- logger = Logger.new(STDOUT)
4
- logger.info hello_req
5
- Souls::HelloReply.new(message: "Hello #{hello_req.name}")
6
- end
7
-
8
- def say_hello_again(hello_req, _unused_call)
9
- logger = Logger.new(STDOUT)
10
- logger.info hello_req
11
- Souls::HelloReply.new(message: "Works Perfect, #{hello_req.name}")
12
- end
13
- end
@@ -1,69 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: blog.proto
3
-
4
- require 'google/protobuf'
5
-
6
- require 'google/protobuf/timestamp_pb'
7
- Google::Protobuf::DescriptorPool.generated_pool.build do
8
- add_file("blog.proto", :syntax => :proto3) do
9
- add_message "Souls.HelloRequest" do
10
- optional :name, :string, 1
11
- end
12
- add_message "Souls.HelloReply" do
13
- optional :message, :string, 1
14
- end
15
- add_message "Souls.Article" do
16
- optional :id, :string, 1
17
- optional :user_id, :string, 2
18
- optional :title, :string, 3
19
- optional :body, :string, 4
20
- optional :thumnail_url, :string, 5
21
- optional :public_date, :uint32, 6
22
- optional :article_category_id, :uint32, 7
23
- optional :is_public, :bool, 8
24
- repeated :tag, :string, 9
25
- optional :has_series, :bool, 10
26
- optional :series_id, :uint32, 11
27
- optional :episode_num, :uint32, 12
28
- optional :created_at, :message, 13, "google.protobuf.Timestamp"
29
- optional :updated_at, :message, 14, "google.protobuf.Timestamp"
30
- end
31
- add_message "Souls.GetArticlRequest" do
32
- optional :id, :uint32, 1
33
- end
34
- add_message "Souls.GetArticleReply" do
35
- optional :article, :message, 1, "Souls.Article"
36
- end
37
- add_message "Souls.GetArticlesRequest" do
38
- optional :search, :string, 1
39
- optional :limit, :uint32, 2
40
- end
41
- add_message "Souls.UpdateArticlesReply" do
42
- repeated :articles, :message, 1, "Souls.Article"
43
- end
44
- add_message "Souls.DeleteArticlRequest" do
45
- optional :id, :uint32, 1
46
- end
47
- add_message "Souls.DeleteArticleReply" do
48
- optional :article, :message, 1, "Souls.Article"
49
- end
50
- add_message "Souls.CreateArticleReply" do
51
- optional :article, :message, 1, "Souls.Article"
52
- end
53
- end
54
- end
55
-
56
- module Souls
57
- HelloRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.HelloRequest").msgclass
58
- HelloReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.HelloReply").msgclass
59
- Article = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.Article").msgclass
60
- GetArticlRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.GetArticlRequest").msgclass
61
- GetArticleReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.GetArticleReply").msgclass
62
- GetArticlesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.GetArticlesRequest").msgclass
63
- UpdateArticlesReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.UpdateArticlesReply").msgclass
64
- DeleteArticlRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.DeleteArticlRequest").msgclass
65
- DeleteArticleReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.DeleteArticleReply").msgclass
66
- CreateArticleReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.CreateArticleReply").msgclass
67
- end
68
- module BlogPb
69
- end
@@ -1,30 +0,0 @@
1
- # Generated by the SOULs protocol buffer compiler. DO NOT EDIT!
2
- # Source: blog.proto for package 'Souls'
3
-
4
- require_relative "blog_pb"
5
- module Souls
6
- module Blog
7
- class Service
8
-
9
- include GRPC::GenericService
10
-
11
- self.marshal_class_method = :encode
12
- self.unmarshal_class_method = :decode
13
- self.service_name = 'Souls.Blog'
14
-
15
- # Sends a greeting
16
- rpc :SayHello, ::Souls::HelloRequest, ::Souls::HelloReply
17
- # Sends another greeting
18
- rpc :SayHelloAgain, ::Souls::HelloRequest, ::Souls::HelloReply
19
- # Blog Service Sample
20
- rpc :GetArticle, ::Souls::GetArticlRequest, ::Souls::GetArticleReply
21
- rpc :GetArticles, ::Souls::GetArticlesRequest, stream(::Souls::Article)
22
- rpc :CreateArticle, ::Souls::Article, ::Souls::CreateArticleReply
23
- rpc :UpdateArticles, stream(::Souls::Article), ::Souls::UpdateArticlesReply
24
- rpc :DeleteArticle, ::Souls::DeleteArticlRequest, ::Souls::DeleteArticleReply
25
- rpc :CreateArticlesInStream, stream(::Souls::Article), stream(::Souls::Article)
26
- end
27
-
28
- Stub = Service.rpc_stub_class
29
- end
30
- end
@@ -1,11 +0,0 @@
1
- Souls.configure do |config|
2
- config.project_id = "elsoul2"
3
- config.app = "blog"
4
- config.network = "elsoul"
5
- config.machine_type = "custom-1-6656"
6
- config.zone = "asia-northeast1-b"
7
- config.domain = "blog.el-soul.com"
8
- config.google_application_credentials = "./config/credentials.json"
9
- config.strain = "service"
10
- config.proto_package_name = "souls"
11
- end
@@ -1,39 +0,0 @@
1
- apiVersion: v1
2
- kind: Service
3
- metadata:
4
- name: souls_service
5
- annotations:
6
- cloud.google.com/neg: '{"exposed_ports":{"8080":{}}}'
7
- spec:
8
- ports:
9
- - port: 8080
10
- name: souls_service
11
- protocol: TCP
12
- targetPort: 50051
13
- selector:
14
- run: souls_service
15
- type: ClusterIP
16
-
17
- ---
18
- apiVersion: apps/v1
19
- kind: Deployment
20
- metadata:
21
- labels:
22
- run: souls_service
23
- name: souls_service
24
- spec:
25
- selector:
26
- matchLabels:
27
- run: souls_service
28
- replicas: 2
29
- template:
30
- metadata:
31
- labels:
32
- run: souls_service
33
- spec:
34
- containers:
35
- - image: asia.gcr.io/elsoul2/souls_service:0.0.1
36
- name: souls_service
37
- ports:
38
- - protocol: TCP
39
- containerPort: 50051
@@ -1,12 +0,0 @@
1
- require "./app"
2
-
3
- def main
4
- s = GRPC::RpcServer.new
5
- s.add_http2_port("0.0.0.0:50051", :this_port_is_insecure)
6
- s.handle(ApplicationController)
7
- logger = Logger.new(STDOUT)
8
- logger.info "Running Server! SOULs Ready on localhost:50051"
9
- s.run_till_terminated_or_interrupted([1, "int", "SIGQUIT"])
10
- end
11
-
12
- main
@@ -1,79 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package Souls;
4
-
5
- import "google/protobuf/timestamp.proto";
6
-
7
- service Blog {
8
- // Sends a greeting
9
- rpc SayHello (HelloRequest) returns (HelloReply) {}
10
- // Sends another greeting
11
- rpc SayHelloAgain (HelloRequest) returns (HelloReply) {}
12
-
13
- // Blog Service Sample
14
- rpc GetArticle(GetArticlRequest) returns (GetArticleReply) {}
15
- rpc GetArticles(GetArticlesRequest) returns (stream Article) {}
16
- rpc CreateArticle(Article) returns (CreateArticleReply) {}
17
- rpc UpdateArticles(stream Article) returns (UpdateArticlesReply) {}
18
- rpc DeleteArticle(DeleteArticlRequest) returns (DeleteArticleReply) {}
19
- rpc CreateArticlesInStream(stream Article) returns (stream Article) {}
20
- }
21
-
22
- // The request message containing the user's name.
23
- message HelloRequest {
24
- string name = 1;
25
- }
26
-
27
- // The response message containing the greetings
28
- message HelloReply {
29
- string message = 1;
30
- }
31
-
32
-
33
- // Blog Protos
34
- message Article {
35
- string id = 1;
36
- string user_id = 2;
37
- string title = 3;
38
- string body = 4;
39
- string thumnail_url = 5;
40
- uint32 public_date = 6;
41
- uint32 article_category_id = 7;
42
- bool is_public = 8;
43
- repeated string tag = 9;
44
- bool has_series = 10;
45
- uint32 series_id = 11;
46
- uint32 episode_num = 12;
47
- google.protobuf.Timestamp created_at = 13;
48
- google.protobuf.Timestamp updated_at = 14;
49
- }
50
-
51
-
52
- message GetArticlRequest {
53
- uint32 id = 1;
54
- }
55
-
56
- message GetArticleReply {
57
- Article article = 1;
58
- }
59
-
60
- message GetArticlesRequest {
61
- string search = 1;
62
- uint32 limit = 2;
63
- }
64
-
65
- message UpdateArticlesReply {
66
- repeated Article articles = 1;
67
- }
68
-
69
- message DeleteArticlRequest {
70
- uint32 id = 1;
71
- }
72
-
73
- message DeleteArticleReply {
74
- Article article = 1;
75
- }
76
-
77
- message CreateArticleReply {
78
- Article article = 1;
79
- }