mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
rename ask to answer
This commit is contained in:
0
ask/.gitignore → answer/.gitignore
vendored
0
ask/.gitignore → answer/.gitignore
vendored
3
answer/Dockerfile
Normal file
3
answer/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM alpine
|
||||||
|
ADD answer /answer
|
||||||
|
ENTRYPOINT [ "/answer" ]
|
||||||
@@ -9,15 +9,15 @@ init:
|
|||||||
|
|
||||||
.PHONY: api
|
.PHONY: api
|
||||||
api:
|
api:
|
||||||
protoc --openapi_out=. --proto_path=. proto/ask.proto
|
protoc --openapi_out=. --proto_path=. proto/answer.proto
|
||||||
|
|
||||||
.PHONY: proto
|
.PHONY: proto
|
||||||
proto:
|
proto:
|
||||||
protoc --proto_path=. --micro_out=. --go_out=:. proto/ask.proto
|
protoc --proto_path=. --micro_out=. --go_out=:. proto/answer.proto
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
go build -o ask *.go
|
go build -o answer *.go
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
@@ -25,4 +25,4 @@ test:
|
|||||||
|
|
||||||
.PHONY: docker
|
.PHONY: docker
|
||||||
docker:
|
docker:
|
||||||
docker build . -t ask:latest
|
docker build . -t answer:latest
|
||||||
@@ -5,19 +5,19 @@ import (
|
|||||||
|
|
||||||
"github.com/m3o/goduckgo/goduckgo"
|
"github.com/m3o/goduckgo/goduckgo"
|
||||||
"github.com/micro/micro/v3/service/errors"
|
"github.com/micro/micro/v3/service/errors"
|
||||||
pb "github.com/micro/services/ask/proto"
|
pb "github.com/micro/services/answer/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Ask struct{}
|
type Answer struct{}
|
||||||
|
|
||||||
func (a *Ask) Question(ctx context.Context, req *pb.QuestionRequest, rsp *pb.QuestionResponse) error {
|
func (a *Answer) Question(ctx context.Context, req *pb.QuestionRequest, rsp *pb.QuestionResponse) error {
|
||||||
if len(req.Query) == 0 {
|
if len(req.Query) == 0 {
|
||||||
return errors.BadRequest("ask.question", "need a question")
|
return errors.BadRequest("answer.question", "need a question")
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := goduckgo.Query(req.Query)
|
msg, err := goduckgo.Query(req.Query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.InternalServerError("ask.question", err.Error())
|
return errors.InternalServerError("answer.question", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(msg.Abstract) > 0 {
|
if len(msg.Abstract) > 0 {
|
||||||
@@ -3,19 +3,19 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/micro/micro/v3/service"
|
"github.com/micro/micro/v3/service"
|
||||||
"github.com/micro/micro/v3/service/logger"
|
"github.com/micro/micro/v3/service/logger"
|
||||||
"github.com/micro/services/ask/handler"
|
"github.com/micro/services/answer/handler"
|
||||||
pb "github.com/micro/services/ask/proto"
|
pb "github.com/micro/services/answer/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Create service
|
// Create service
|
||||||
srv := service.New(
|
srv := service.New(
|
||||||
service.Name("ask"),
|
service.Name("answer"),
|
||||||
service.Version("latest"),
|
service.Version("latest"),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register handler
|
// Register handler
|
||||||
pb.RegisterAskHandler(srv.Server(), new(handler.Ask))
|
pb.RegisterAnswerHandler(srv.Server(), new(handler.Answer))
|
||||||
|
|
||||||
// Run service
|
// Run service
|
||||||
if err := srv.Run(); err != nil {
|
if err := srv.Run(); err != nil {
|
||||||
1
answer/micro.mu
Normal file
1
answer/micro.mu
Normal file
@@ -0,0 +1 @@
|
|||||||
|
service answer
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.26.0
|
// protoc-gen-go v1.26.0
|
||||||
// protoc v3.15.6
|
// protoc v3.15.6
|
||||||
// source: proto/ask.proto
|
// source: proto/answer.proto
|
||||||
|
|
||||||
package ask
|
package answer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
@@ -20,20 +20,20 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ask a question and receive an instant answer
|
// Answer a question and receive an instant answer
|
||||||
type QuestionRequest struct {
|
type QuestionRequest struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// the question to ask
|
// the question to answer
|
||||||
Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
|
Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *QuestionRequest) Reset() {
|
func (x *QuestionRequest) Reset() {
|
||||||
*x = QuestionRequest{}
|
*x = QuestionRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_proto_ask_proto_msgTypes[0]
|
mi := &file_proto_answer_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ func (x *QuestionRequest) String() string {
|
|||||||
func (*QuestionRequest) ProtoMessage() {}
|
func (*QuestionRequest) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *QuestionRequest) ProtoReflect() protoreflect.Message {
|
func (x *QuestionRequest) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_proto_ask_proto_msgTypes[0]
|
mi := &file_proto_answer_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -59,7 +59,7 @@ func (x *QuestionRequest) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use QuestionRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use QuestionRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*QuestionRequest) Descriptor() ([]byte, []int) {
|
func (*QuestionRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_proto_ask_proto_rawDescGZIP(), []int{0}
|
return file_proto_answer_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *QuestionRequest) GetQuery() string {
|
func (x *QuestionRequest) GetQuery() string {
|
||||||
@@ -85,7 +85,7 @@ type QuestionResponse struct {
|
|||||||
func (x *QuestionResponse) Reset() {
|
func (x *QuestionResponse) Reset() {
|
||||||
*x = QuestionResponse{}
|
*x = QuestionResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_proto_ask_proto_msgTypes[1]
|
mi := &file_proto_answer_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ func (x *QuestionResponse) String() string {
|
|||||||
func (*QuestionResponse) ProtoMessage() {}
|
func (*QuestionResponse) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *QuestionResponse) ProtoReflect() protoreflect.Message {
|
func (x *QuestionResponse) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_proto_ask_proto_msgTypes[1]
|
mi := &file_proto_answer_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -111,7 +111,7 @@ func (x *QuestionResponse) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use QuestionResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use QuestionResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*QuestionResponse) Descriptor() ([]byte, []int) {
|
func (*QuestionResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_proto_ask_proto_rawDescGZIP(), []int{1}
|
return file_proto_answer_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *QuestionResponse) GetAnswer() string {
|
func (x *QuestionResponse) GetAnswer() string {
|
||||||
@@ -135,46 +135,47 @@ func (x *QuestionResponse) GetImage() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_proto_ask_proto protoreflect.FileDescriptor
|
var File_proto_answer_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_proto_ask_proto_rawDesc = []byte{
|
var file_proto_answer_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x2e, 0x70,
|
||||||
0x6f, 0x12, 0x03, 0x61, 0x73, 0x6b, 0x22, 0x27, 0x0a, 0x0f, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69,
|
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x22, 0x27, 0x0a, 0x0f,
|
||||||
0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65,
|
0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||||
0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22,
|
0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
|
||||||
0x52, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x52, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f,
|
||||||
0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x01, 0x20,
|
0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6e, 0x73,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75,
|
0x77, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65,
|
||||||
0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x14, 0x0a,
|
0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
||||||
0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6d,
|
0x75, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01,
|
||||||
0x61, 0x67, 0x65, 0x32, 0x40, 0x0a, 0x03, 0x41, 0x73, 0x6b, 0x12, 0x39, 0x0a, 0x08, 0x51, 0x75,
|
0x28, 0x09, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x32, 0x49, 0x0a, 0x06, 0x41, 0x6e, 0x73,
|
||||||
0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x2e, 0x61, 0x73, 0x6b, 0x2e, 0x51, 0x75, 0x65,
|
0x77, 0x65, 0x72, 0x12, 0x3f, 0x0a, 0x08, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12,
|
||||||
0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x61,
|
0x17, 0x2e, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x2e, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f,
|
||||||
0x73, 0x6b, 0x2e, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x61, 0x6e, 0x73, 0x77, 0x65,
|
||||||
0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x72, 0x2e, 0x51, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||||
0x3b, 0x61, 0x73, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x73, 0x65, 0x22, 0x00, 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b,
|
||||||
|
0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_proto_ask_proto_rawDescOnce sync.Once
|
file_proto_answer_proto_rawDescOnce sync.Once
|
||||||
file_proto_ask_proto_rawDescData = file_proto_ask_proto_rawDesc
|
file_proto_answer_proto_rawDescData = file_proto_answer_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_proto_ask_proto_rawDescGZIP() []byte {
|
func file_proto_answer_proto_rawDescGZIP() []byte {
|
||||||
file_proto_ask_proto_rawDescOnce.Do(func() {
|
file_proto_answer_proto_rawDescOnce.Do(func() {
|
||||||
file_proto_ask_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_ask_proto_rawDescData)
|
file_proto_answer_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_answer_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_proto_ask_proto_rawDescData
|
return file_proto_answer_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_proto_ask_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
var file_proto_answer_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||||
var file_proto_ask_proto_goTypes = []interface{}{
|
var file_proto_answer_proto_goTypes = []interface{}{
|
||||||
(*QuestionRequest)(nil), // 0: ask.QuestionRequest
|
(*QuestionRequest)(nil), // 0: answer.QuestionRequest
|
||||||
(*QuestionResponse)(nil), // 1: ask.QuestionResponse
|
(*QuestionResponse)(nil), // 1: answer.QuestionResponse
|
||||||
}
|
}
|
||||||
var file_proto_ask_proto_depIdxs = []int32{
|
var file_proto_answer_proto_depIdxs = []int32{
|
||||||
0, // 0: ask.Ask.Question:input_type -> ask.QuestionRequest
|
0, // 0: answer.Answer.Question:input_type -> answer.QuestionRequest
|
||||||
1, // 1: ask.Ask.Question:output_type -> ask.QuestionResponse
|
1, // 1: answer.Answer.Question:output_type -> answer.QuestionResponse
|
||||||
1, // [1:2] is the sub-list for method output_type
|
1, // [1:2] is the sub-list for method output_type
|
||||||
0, // [0:1] is the sub-list for method input_type
|
0, // [0:1] is the sub-list for method input_type
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
@@ -182,13 +183,13 @@ var file_proto_ask_proto_depIdxs = []int32{
|
|||||||
0, // [0:0] is the sub-list for field type_name
|
0, // [0:0] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_proto_ask_proto_init() }
|
func init() { file_proto_answer_proto_init() }
|
||||||
func file_proto_ask_proto_init() {
|
func file_proto_answer_proto_init() {
|
||||||
if File_proto_ask_proto != nil {
|
if File_proto_answer_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_proto_ask_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_proto_answer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*QuestionRequest); i {
|
switch v := v.(*QuestionRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -200,7 +201,7 @@ func file_proto_ask_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_proto_ask_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
file_proto_answer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*QuestionResponse); i {
|
switch v := v.(*QuestionResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -217,18 +218,18 @@ func file_proto_ask_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_proto_ask_proto_rawDesc,
|
RawDescriptor: file_proto_answer_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 2,
|
NumMessages: 2,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
GoTypes: file_proto_ask_proto_goTypes,
|
GoTypes: file_proto_answer_proto_goTypes,
|
||||||
DependencyIndexes: file_proto_ask_proto_depIdxs,
|
DependencyIndexes: file_proto_answer_proto_depIdxs,
|
||||||
MessageInfos: file_proto_ask_proto_msgTypes,
|
MessageInfos: file_proto_answer_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_proto_ask_proto = out.File
|
File_proto_answer_proto = out.File
|
||||||
file_proto_ask_proto_rawDesc = nil
|
file_proto_answer_proto_rawDesc = nil
|
||||||
file_proto_ask_proto_goTypes = nil
|
file_proto_answer_proto_goTypes = nil
|
||||||
file_proto_ask_proto_depIdxs = nil
|
file_proto_answer_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||||
// source: proto/ask.proto
|
// source: proto/answer.proto
|
||||||
|
|
||||||
package ask
|
package answer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
@@ -33,32 +33,32 @@ var _ context.Context
|
|||||||
var _ client.Option
|
var _ client.Option
|
||||||
var _ server.Option
|
var _ server.Option
|
||||||
|
|
||||||
// Api Endpoints for Ask service
|
// Api Endpoints for Answer service
|
||||||
|
|
||||||
func NewAskEndpoints() []*api.Endpoint {
|
func NewAnswerEndpoints() []*api.Endpoint {
|
||||||
return []*api.Endpoint{}
|
return []*api.Endpoint{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client API for Ask service
|
// Client API for Answer service
|
||||||
|
|
||||||
type AskService interface {
|
type AnswerService interface {
|
||||||
Question(ctx context.Context, in *QuestionRequest, opts ...client.CallOption) (*QuestionResponse, error)
|
Question(ctx context.Context, in *QuestionRequest, opts ...client.CallOption) (*QuestionResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type askService struct {
|
type answerService struct {
|
||||||
c client.Client
|
c client.Client
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAskService(name string, c client.Client) AskService {
|
func NewAnswerService(name string, c client.Client) AnswerService {
|
||||||
return &askService{
|
return &answerService{
|
||||||
c: c,
|
c: c,
|
||||||
name: name,
|
name: name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *askService) Question(ctx context.Context, in *QuestionRequest, opts ...client.CallOption) (*QuestionResponse, error) {
|
func (c *answerService) Question(ctx context.Context, in *QuestionRequest, opts ...client.CallOption) (*QuestionResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "Ask.Question", in)
|
req := c.c.NewRequest(c.name, "Answer.Question", in)
|
||||||
out := new(QuestionResponse)
|
out := new(QuestionResponse)
|
||||||
err := c.c.Call(ctx, req, out, opts...)
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -67,27 +67,27 @@ func (c *askService) Question(ctx context.Context, in *QuestionRequest, opts ...
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server API for Ask service
|
// Server API for Answer service
|
||||||
|
|
||||||
type AskHandler interface {
|
type AnswerHandler interface {
|
||||||
Question(context.Context, *QuestionRequest, *QuestionResponse) error
|
Question(context.Context, *QuestionRequest, *QuestionResponse) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterAskHandler(s server.Server, hdlr AskHandler, opts ...server.HandlerOption) error {
|
func RegisterAnswerHandler(s server.Server, hdlr AnswerHandler, opts ...server.HandlerOption) error {
|
||||||
type ask interface {
|
type answer interface {
|
||||||
Question(ctx context.Context, in *QuestionRequest, out *QuestionResponse) error
|
Question(ctx context.Context, in *QuestionRequest, out *QuestionResponse) error
|
||||||
}
|
}
|
||||||
type Ask struct {
|
type Answer struct {
|
||||||
ask
|
answer
|
||||||
}
|
}
|
||||||
h := &askHandler{hdlr}
|
h := &answerHandler{hdlr}
|
||||||
return s.Handle(s.NewHandler(&Ask{h}, opts...))
|
return s.Handle(s.NewHandler(&Answer{h}, opts...))
|
||||||
}
|
}
|
||||||
|
|
||||||
type askHandler struct {
|
type answerHandler struct {
|
||||||
AskHandler
|
AnswerHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *askHandler) Question(ctx context.Context, in *QuestionRequest, out *QuestionResponse) error {
|
func (h *answerHandler) Question(ctx context.Context, in *QuestionRequest, out *QuestionResponse) error {
|
||||||
return h.AskHandler.Question(ctx, in, out)
|
return h.AnswerHandler.Question(ctx, in, out)
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package ask;
|
package answer;
|
||||||
|
|
||||||
option go_package = "./proto;ask";
|
option go_package = "./proto;answer";
|
||||||
|
|
||||||
service Ask {
|
service Answer {
|
||||||
rpc Question(QuestionRequest) returns (QuestionResponse) {}
|
rpc Question(QuestionRequest) returns (QuestionResponse) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask a question and receive an instant answer
|
// Answer a question and receive an instant answer
|
||||||
message QuestionRequest {
|
message QuestionRequest {
|
||||||
// the question to ask
|
// the question to answer
|
||||||
string query = 1;
|
string query = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "ask",
|
"name": "answer",
|
||||||
"icon": "❓",
|
"icon": "❓",
|
||||||
"category": "search"
|
"category": "search"
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
FROM alpine
|
|
||||||
ADD ask /ask
|
|
||||||
ENTRYPOINT [ "/ask" ]
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
service ask
|
|
||||||
Reference in New Issue
Block a user