-
Notifications
You must be signed in to change notification settings - Fork 59
/
Endpoint.pbrpc.m
140 lines (120 loc) · 5.99 KB
/
Endpoint.pbrpc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#if !defined(GPB_GRPC_PROTOCOL_ONLY) || !GPB_GRPC_PROTOCOL_ONLY
#import "Endpoint.pbrpc.h"
#import "Endpoint.pbobjc.h"
#import <ProtoRPC/ProtoRPC.h>
#import <RxLibrary/GRXWriter+Immediate.h>
#import "Transaction.pbobjc.h"
#import "Queries.pbobjc.h"
#import "QryResponses.pbobjc.h"
#if defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS) && GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/Empty.pbobjc.h>
#else
#import "google/protobuf/Empty.pbobjc.h"
#endif
@implementation CommandService_v1
// Designated initializer
- (instancetype)initWithHost:(NSString *)host {
self = [super initWithHost:host
packageName:@"iroha.protocol"
serviceName:@"CommandService_v1"];
return self;
}
// Override superclass initializer to disallow different package and service names.
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
serviceName:(NSString *)serviceName {
return [self initWithHost:host];
}
#pragma mark - Class Methods
+ (instancetype)serviceWithHost:(NSString *)host {
return [[self alloc] initWithHost:host];
}
#pragma mark - Method Implementations
#pragma mark Torii(Transaction) returns (Empty)
- (void)toriiWithRequest:(Transaction *)request handler:(void(^)(GPBEmpty *_Nullable response, NSError *_Nullable error))handler{
[[self RPCToToriiWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (GRPCProtoCall *)RPCToToriiWithRequest:(Transaction *)request handler:(void(^)(GPBEmpty *_Nullable response, NSError *_Nullable error))handler{
return [self RPCToMethod:@"Torii"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[GPBEmpty class]
responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]];
}
#pragma mark ListTorii(TxList) returns (Empty)
- (void)listToriiWithRequest:(TxList *)request handler:(void(^)(GPBEmpty *_Nullable response, NSError *_Nullable error))handler{
[[self RPCToListToriiWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (GRPCProtoCall *)RPCToListToriiWithRequest:(TxList *)request handler:(void(^)(GPBEmpty *_Nullable response, NSError *_Nullable error))handler{
return [self RPCToMethod:@"ListTorii"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[GPBEmpty class]
responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]];
}
#pragma mark Status(TxStatusRequest) returns (ToriiResponse)
- (void)statusWithRequest:(TxStatusRequest *)request handler:(void(^)(ToriiResponse *_Nullable response, NSError *_Nullable error))handler{
[[self RPCToStatusWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (GRPCProtoCall *)RPCToStatusWithRequest:(TxStatusRequest *)request handler:(void(^)(ToriiResponse *_Nullable response, NSError *_Nullable error))handler{
return [self RPCToMethod:@"Status"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[ToriiResponse class]
responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]];
}
#pragma mark StatusStream(TxStatusRequest) returns (stream ToriiResponse)
- (void)statusStreamWithRequest:(TxStatusRequest *)request eventHandler:(void(^)(BOOL done, ToriiResponse *_Nullable response, NSError *_Nullable error))eventHandler{
[[self RPCToStatusStreamWithRequest:request eventHandler:eventHandler] start];
}
// Returns a not-yet-started RPC object.
- (GRPCProtoCall *)RPCToStatusStreamWithRequest:(TxStatusRequest *)request eventHandler:(void(^)(BOOL done, ToriiResponse *_Nullable response, NSError *_Nullable error))eventHandler{
return [self RPCToMethod:@"StatusStream"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[ToriiResponse class]
responsesWriteable:[GRXWriteable writeableWithEventHandler:eventHandler]];
}
@end
@implementation QueryService_v1
// Designated initializer
- (instancetype)initWithHost:(NSString *)host {
self = [super initWithHost:host
packageName:@"iroha.protocol"
serviceName:@"QueryService_v1"];
return self;
}
// Override superclass initializer to disallow different package and service names.
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
serviceName:(NSString *)serviceName {
return [self initWithHost:host];
}
#pragma mark - Class Methods
+ (instancetype)serviceWithHost:(NSString *)host {
return [[self alloc] initWithHost:host];
}
#pragma mark - Method Implementations
#pragma mark Find(Query) returns (QueryResponse)
- (void)findWithRequest:(Query *)request handler:(void(^)(QueryResponse *_Nullable response, NSError *_Nullable error))handler{
[[self RPCToFindWithRequest:request handler:handler] start];
}
// Returns a not-yet-started RPC object.
- (GRPCProtoCall *)RPCToFindWithRequest:(Query *)request handler:(void(^)(QueryResponse *_Nullable response, NSError *_Nullable error))handler{
return [self RPCToMethod:@"Find"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[QueryResponse class]
responsesWriteable:[GRXWriteable writeableWithSingleHandler:handler]];
}
#pragma mark FetchCommits(BlocksQuery) returns (stream BlockQueryResponse)
- (void)fetchCommitsWithRequest:(BlocksQuery *)request eventHandler:(void(^)(BOOL done, BlockQueryResponse *_Nullable response, NSError *_Nullable error))eventHandler{
[[self RPCToFetchCommitsWithRequest:request eventHandler:eventHandler] start];
}
// Returns a not-yet-started RPC object.
- (GRPCProtoCall *)RPCToFetchCommitsWithRequest:(BlocksQuery *)request eventHandler:(void(^)(BOOL done, BlockQueryResponse *_Nullable response, NSError *_Nullable error))eventHandler{
return [self RPCToMethod:@"FetchCommits"
requestsWriter:[GRXWriter writerWithValue:request]
responseClass:[BlockQueryResponse class]
responsesWriteable:[GRXWriteable writeableWithEventHandler:eventHandler]];
}
@end
#endif