Class: Grpc::Client::ORiN3::Provider::ORiN3File
Instance Attribute Summary collapse
#name, #option, #orin3_object_type, #type_name
Instance Method Summary
collapse
#close, #open
#execute, #get_status, #get_tag, #get_tag_keys, #id, #remove_tag, #set_tag
Constructor Details
#initialize(channel, internal_id, created_datetime) ⇒ ORiN3File
Returns a new instance of ORiN3File.
21
22
23
24
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 21
def initialize(channel, internal_id, created_datetime)
@created_datetime = created_datetime
super(channel, internal_id)
end
|
Instance Attribute Details
#created_datetime ⇒ Object
Returns the value of attribute created_datetime.
18
19
20
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 18
def created_datetime
@created_datetime
end
|
Instance Method Details
#can_read ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 80
def can_read
begin
file = O3::FileService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
request = O3::CanReadFileRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
response = file.can_read(request)
if (response.common.result_code != :SUCCEEDED)
raise MessageClientError.new(response.common.result_code, response.common.detail)
end
return response.can_read
rescue MessageClientError
raise
rescue StandardError => e
raise MessageClientError.new(e)
end
end
|
#can_write ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 96
def can_write
begin
file = O3::FileService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
request = O3::CanWriteFileRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
response = file.can_write(request)
if (response.common.result_code != :SUCCEEDED)
raise MessageClientError.new(response.common.result_code, response.common.detail)
end
return response.can_write
rescue MessageClientError
raise
rescue StandardError => e
raise MessageClientError.new(e)
end
end
|
#get_length ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 112
def get_length
begin
file = O3::FileService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
request = O3::GetFileLengthRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
response = file.get_length(request)
if (response.common.result_code != :SUCCEEDED)
raise MessageClientError.new(response.common.result_code, response.common.detail)
end
return response.length
rescue MessageClientError
raise
rescue StandardError => e
raise MessageClientError.new(e)
end
end
|
#read(buffer_size = 1048576) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 26
def read(buffer_size = 1048576)
begin
file = O3::FileService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
request = O3::ReadFileRequest.new(common: O3P::CommonRequest.new, id: @internal_id, buffer_size: buffer_size)
responses = file.read(request)
responses.each do |response|
if response.common.result_code != :SUCCEEDED
raise MessageClientError.new(response.common.result_code, response.common.detail)
end
yield response.buffer if block_given?
end
rescue MessageClientError
raise
rescue StandardError => e
raise MessageClientError.new(e)
end
end
|
#seek(offset, origin = :BEGIN) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 64
def seek(offset, origin = :BEGIN)
begin
file = O3::FileService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
request = O3::SeekFileRequest.new(common: O3P::CommonRequest.new, id: @internal_id, offset: offset, origin: origin)
response = file.seek(request)
if (response.common.result_code != :SUCCEEDED)
raise MessageClientError.new(response.common.result_code, response.common.detail)
end
return response.position
rescue MessageClientError
raise
rescue StandardError => e
raise MessageClientError.new(e)
end
end
|
#set_length(length) ⇒ Object
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 128
def set_length(length)
begin
file = O3::FileService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
request = O3::SetFileLengthRequest.new(common: O3P::CommonRequest.new, id: @internal_id, length: length)
response = file.set_length(request)
if (response.common.result_code != :SUCCEEDED)
raise MessageClientError.new(response.common.result_code, response.common.detail)
end
rescue MessageClientError
raise
rescue StandardError => e
raise MessageClientError.new(e)
end
end
|
#write(buffer) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/grpc/client/orin3/provider/orin3_file.rb', line 44
def write(buffer)
begin
file = O3::FileService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
request = O3::WriteFileRequest.new(common: O3P::CommonRequest.new, id: @internal_id, buffer: buffer, total_length: buffer.length)
response = file.write(
Enumerator.new do |yielder|
yielder << request
end
)
if response.common.result_code != :SUCCEEDED
raise MessageClientError.new(response.common.result_code, response.common.detail)
end
rescue MessageClientError
raise
rescue StandardError => e
raise MessageClientError.new(e)
end
end
|