Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c3ae09e

Browse files
Initial source code (working example of kafka streams + tensorflow serving)
1 parent b57bbef commit c3ae09e

File tree

6 files changed

+1593
-0
lines changed

6 files changed

+1593
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.github.megachucky.kafka.streams.machinelearning;
19+
20+
import io.grpc.CallOptions;
21+
import io.grpc.Channel;
22+
import io.grpc.ExperimentalApi;
23+
import io.grpc.MethodDescriptor;
24+
import io.grpc.MethodDescriptor.MethodType;
25+
import io.grpc.protobuf.ProtoUtils;
26+
import io.grpc.stub.AbstractStub;
27+
28+
import static com.github.megachucky.kafka.streams.machinelearning.InceptionInference.InceptionRequest;
29+
import static com.github.megachucky.kafka.streams.machinelearning.InceptionInference.InceptionResponse;
30+
import static io.grpc.MethodDescriptor.generateFullMethodName;
31+
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
32+
33+
/**
34+
* Stub implementation for {@link #SERVICE_NAME} (Tensorflow' Inception service )
35+
* @author Thamme Gowda
36+
*/
37+
public class InceptionBlockingStub extends AbstractStub<InceptionBlockingStub> {
38+
39+
public static final String SERVICE_NAME = "tensorflow.serving.InceptionService";
40+
public static final String METHOD_NAME = "Classify";
41+
42+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
43+
public static final MethodDescriptor<InceptionRequest, InceptionResponse> METHOD_DESCRIPTOR = MethodDescriptor
44+
.create(MethodType.UNARY,
45+
generateFullMethodName(SERVICE_NAME, METHOD_NAME),
46+
ProtoUtils.marshaller(InceptionRequest.getDefaultInstance()),
47+
ProtoUtils.marshaller(InceptionResponse.getDefaultInstance()));
48+
49+
public InceptionBlockingStub(Channel channel) {
50+
super(channel);
51+
}
52+
53+
private InceptionBlockingStub(Channel channel, CallOptions callOptions) {
54+
super(channel, callOptions);
55+
}
56+
57+
@Override
58+
protected InceptionBlockingStub build(Channel channel,
59+
CallOptions callOptions) {
60+
return new InceptionBlockingStub(channel, callOptions);
61+
}
62+
63+
public InceptionResponse classify(InceptionRequest request) {
64+
return blockingUnaryCall(getChannel(), METHOD_DESCRIPTOR, getCallOptions(),
65+
request);
66+
}
67+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /