cf-copilot 0.0.10 → 0.0.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a62e8b7ba6fb70c4fffddbb7f5fbaf740c925e65
4
- data.tar.gz: 51a2aaba858b3d952917884ebbafda2a21fac90a
3
+ metadata.gz: ebdd8f28720f1f877bd5980b514e21f893fc729b
4
+ data.tar.gz: ef5214cf5d19f36bddea913af76af02b06b481a7
5
5
  SHA512:
6
- metadata.gz: 44369baf48358fa3f040d00a9371e937742f5264fc3f30dc5a26f7a2abe55097c4e465c2cb0576db8a1f4be32e920dee0865238e121b43d36be4818882cd05b1
7
- data.tar.gz: 361077971c77cf9aee465e3dbafbc10abf7a8aa4056b3d0c761756673306f9b32a079c7a0ee6be0ceb88d8eda417f29d9bf08921d3ef64656db251b0ed81b76a
6
+ metadata.gz: f067cc538457570894890080a75ef2350b4d8d229f3161a4b5d610c70a418e7e17ea52ec9df87924403e00eee1bb08f5c80d97754a0bd1520e8f7c69c922d474
7
+ data.tar.gz: 183463bc6fedfc8a460c2348b8a896a4fb6d5b5a58535be1f5ba0293609e7ca843cf39754159c5d3c25e94bf8f2e963e1cdcab07fa7c620993e931031fe2cdf5
@@ -2,11 +2,13 @@
2
2
 
3
3
  require 'copilot/protos/cloud_controller_pb'
4
4
  require 'copilot/protos/cloud_controller_services_pb'
5
+ require 'pry'
5
6
 
6
7
  module Cloudfoundry
7
8
  module Copilot
8
9
  class Client
9
10
  class PilotError < StandardError; end
11
+ CHUNK_SIZE = 64 * 1024 # 64KB
10
12
 
11
13
  attr_reader :host, :port
12
14
 
@@ -78,13 +80,37 @@ module Cloudfoundry
78
80
  raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.metadata}"
79
81
  end
80
82
 
83
+ class BulkSyncEnum
84
+ def initialize(routes, route_mappings, capi_diego_process_associations)
85
+ @routes = routes
86
+ @route_mappings = route_mappings
87
+ @capi_diego_process_associations = capi_diego_process_associations
88
+ end
89
+
90
+ def each
91
+ return enum_for(:each) unless block_given?
92
+ request = Api::BulkSyncRequest.new(
93
+ routes: @routes,
94
+ route_mappings: @route_mappings,
95
+ capi_diego_process_associations: @capi_diego_process_associations
96
+ )
97
+
98
+ all_bytes = request.to_proto
99
+
100
+ current_byte = 0
101
+ request_bytes_length = all_bytes.length
102
+ while current_byte < request_bytes_length
103
+ yield Api::BulkSyncRequestChunk.new(chunk: all_bytes[current_byte..current_byte + CHUNK_SIZE - 1].to_s)
104
+ current_byte += CHUNK_SIZE
105
+ end
106
+ yield Api::BulkSyncRequestChunk.new(chunk: all_bytes[current_byte..request_bytes_length-1].to_s)
107
+ end
108
+
109
+ end
110
+
81
111
  def bulk_sync(routes:, route_mappings:, capi_diego_process_associations:)
82
- request = Api::BulkSyncRequest.new(
83
- routes: routes,
84
- route_mappings: route_mappings,
85
- capi_diego_process_associations: capi_diego_process_associations
86
- )
87
- service.bulk_sync(request)
112
+ bs_enum = BulkSyncEnum.new(routes, route_mappings, capi_diego_process_associations)
113
+ service.bulk_sync(bs_enum.each)
88
114
  rescue GRPC::BadStatus => e
89
115
  raise Cloudfoundry::Copilot::Client::PilotError, "#{e.details} - #{e.metadata}"
90
116
  end
@@ -98,7 +124,6 @@ module Cloudfoundry
98
124
  def compression_options
99
125
  @compression_options ||= GRPC::Core::CompressionOptions.new(
100
126
  default_algorithm: :gzip,
101
- # we could tweak this is compression is not sufficient
102
127
  default_level: :low
103
128
  )
104
129
  end
@@ -73,7 +73,11 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
73
73
  repeated :routes, :message, 2, "api.Route"
74
74
  repeated :capi_diego_process_associations, :message, 3, "api.CapiDiegoProcessAssociation"
75
75
  end
76
+ add_message "api.BulkSyncRequestChunk" do
77
+ optional :chunk, :bytes, 1
78
+ end
76
79
  add_message "api.BulkSyncResponse" do
80
+ optional :total_bytes_received, :int32, 1
77
81
  end
78
82
  end
79
83
 
@@ -101,5 +105,6 @@ module Api
101
105
  DeleteCapiDiegoProcessAssociationRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("api.DeleteCapiDiegoProcessAssociationRequest").msgclass
102
106
  DeleteCapiDiegoProcessAssociationResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("api.DeleteCapiDiegoProcessAssociationResponse").msgclass
103
107
  BulkSyncRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("api.BulkSyncRequest").msgclass
108
+ BulkSyncRequestChunk = Google::Protobuf::DescriptorPool.generated_pool.lookup("api.BulkSyncRequestChunk").msgclass
104
109
  BulkSyncResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("api.BulkSyncResponse").msgclass
105
110
  end
@@ -23,7 +23,7 @@ module Api
23
23
  rpc :UnmapRoute, UnmapRouteRequest, UnmapRouteResponse
24
24
  rpc :UpsertCapiDiegoProcessAssociation, UpsertCapiDiegoProcessAssociationRequest, UpsertCapiDiegoProcessAssociationResponse
25
25
  rpc :DeleteCapiDiegoProcessAssociation, DeleteCapiDiegoProcessAssociationRequest, DeleteCapiDiegoProcessAssociationResponse
26
- rpc :BulkSync, BulkSyncRequest, BulkSyncResponse
26
+ rpc :BulkSync, stream(BulkSyncRequestChunk), BulkSyncResponse
27
27
  rpc :Health, HealthRequest, HealthResponse
28
28
  end
29
29
 
@@ -1,5 +1,5 @@
1
1
  module Cloudfoundry
2
2
  module Copilot
3
- VERSION = '0.0.10'.freeze
3
+ VERSION = '0.0.11'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf-copilot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloud Foundry Routing Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-14 00:00:00.000000000 Z
11
+ date: 2018-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc