From 8bc3cd04113f186318505e527f715c1c5ada4a0a Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 13 Oct 2020 10:02:39 +0100 Subject: [PATCH] Search not implement --- blog/search/.gitignore | 2 - blog/search/Dockerfile | 3 - blog/search/Makefile | 22 --- blog/search/README.md | 55 ------ blog/search/generate.go | 3 - blog/search/handler/search.go | 20 --- blog/search/main.go | 22 --- blog/search/proto/search.pb.go | 245 --------------------------- blog/search/proto/search.pb.micro.go | 110 ------------ blog/search/proto/search.proto | 27 --- 10 files changed, 509 deletions(-) delete mode 100644 blog/search/.gitignore delete mode 100644 blog/search/Dockerfile delete mode 100644 blog/search/Makefile delete mode 100644 blog/search/README.md delete mode 100644 blog/search/generate.go delete mode 100644 blog/search/handler/search.go delete mode 100644 blog/search/main.go delete mode 100644 blog/search/proto/search.pb.go delete mode 100644 blog/search/proto/search.pb.micro.go delete mode 100644 blog/search/proto/search.proto diff --git a/blog/search/.gitignore b/blog/search/.gitignore deleted file mode 100644 index 06316ac..0000000 --- a/blog/search/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ - -search-service diff --git a/blog/search/Dockerfile b/blog/search/Dockerfile deleted file mode 100644 index 9108488..0000000 --- a/blog/search/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM alpine -ADD search-service /search-service -ENTRYPOINT [ "/search-service" ] diff --git a/blog/search/Makefile b/blog/search/Makefile deleted file mode 100644 index ab2dac8..0000000 --- a/blog/search/Makefile +++ /dev/null @@ -1,22 +0,0 @@ - -GOPATH:=$(shell go env GOPATH) -MODIFY=Mgithub.com/micro/go-micro/api/proto/api.proto=github.com/micro/go-micro/v3/api/proto - -.PHONY: proto -proto: - - protoc --proto_path=. --micro_out=${MODIFY}:. --go_out=${MODIFY}:. proto/search/search.proto - - -.PHONY: build -build: proto - - go build -o search-service *.go - -.PHONY: test -test: - go test -v ./... -cover - -.PHONY: docker -docker: - docker build . -t search-service:latest diff --git a/blog/search/README.md b/blog/search/README.md deleted file mode 100644 index 2597e6e..0000000 --- a/blog/search/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Search Service - -This is the Search service - -Generated with - -``` -micro new --namespace=go.micro --type=service search -``` - -## Getting Started - -- [Configuration](#configuration) -- [Dependencies](#dependencies) -- [Usage](#usage) - -## Configuration - -- FQDN: go.micro.service.search -- Type: service -- Alias: search - -## Dependencies - -Micro services depend on service discovery. The default is multicast DNS, a zeroconf system. - -In the event you need a resilient multi-host setup we recommend etcd. - -``` -# install etcd -brew install etcd - -# run etcd -etcd -``` - -## Usage - -A Makefile is included for convenience - -Build the binary - -``` -make build -``` - -Run the service -``` -./search-service -``` - -Build a docker image -``` -make docker -``` \ No newline at end of file diff --git a/blog/search/generate.go b/blog/search/generate.go deleted file mode 100644 index 7d9db91..0000000 --- a/blog/search/generate.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -//go:generate make proto diff --git a/blog/search/handler/search.go b/blog/search/handler/search.go deleted file mode 100644 index f04998a..0000000 --- a/blog/search/handler/search.go +++ /dev/null @@ -1,20 +0,0 @@ -package handler - -import ( - "context" - - "github.com/micro/micro/v3/service/logger" - pb "github.com/micro/services/blog/search/proto" -) - -type Search struct{} - -func (s *Search) Index(ctx context.Context, req *pb.IndexRequest, rsp *pb.IndexResponse) error { - logger.Info("Received Search.Index request") - return nil -} - -func (s *Search) Search(ctx context.Context, req *pb.SearchRequest, rsp *pb.SearchResponse) error { - logger.Info("Received Search.Search request") - return nil -} diff --git a/blog/search/main.go b/blog/search/main.go deleted file mode 100644 index 454dab6..0000000 --- a/blog/search/main.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import ( - "github.com/micro/micro/v3/service" - "github.com/micro/micro/v3/service/logger" - "github.com/micro/services/blog/search/handler" -) - -func main() { - // Create service - srv := service.New( - service.Name("search"), - ) - - // Register Handler - srv.Handle(new(handler.Search)) - - // Run service - if err := srv.Run(); err != nil { - logger.Fatal(err) - } -} diff --git a/blog/search/proto/search.pb.go b/blog/search/proto/search.pb.go deleted file mode 100644 index 9f337fb..0000000 --- a/blog/search/proto/search.pb.go +++ /dev/null @@ -1,245 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: blog/search/proto/search.proto - -package search - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type Document struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Document) Reset() { *m = Document{} } -func (m *Document) String() string { return proto.CompactTextString(m) } -func (*Document) ProtoMessage() {} -func (*Document) Descriptor() ([]byte, []int) { - return fileDescriptor_5c88c8197db8a717, []int{0} -} - -func (m *Document) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Document.Unmarshal(m, b) -} -func (m *Document) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Document.Marshal(b, m, deterministic) -} -func (m *Document) XXX_Merge(src proto.Message) { - xxx_messageInfo_Document.Merge(m, src) -} -func (m *Document) XXX_Size() int { - return xxx_messageInfo_Document.Size(m) -} -func (m *Document) XXX_DiscardUnknown() { - xxx_messageInfo_Document.DiscardUnknown(m) -} - -var xxx_messageInfo_Document proto.InternalMessageInfo - -func (m *Document) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Document) GetText() string { - if m != nil { - return m.Text - } - return "" -} - -type IndexRequest struct { - Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *IndexRequest) Reset() { *m = IndexRequest{} } -func (m *IndexRequest) String() string { return proto.CompactTextString(m) } -func (*IndexRequest) ProtoMessage() {} -func (*IndexRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5c88c8197db8a717, []int{1} -} - -func (m *IndexRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_IndexRequest.Unmarshal(m, b) -} -func (m *IndexRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_IndexRequest.Marshal(b, m, deterministic) -} -func (m *IndexRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_IndexRequest.Merge(m, src) -} -func (m *IndexRequest) XXX_Size() int { - return xxx_messageInfo_IndexRequest.Size(m) -} -func (m *IndexRequest) XXX_DiscardUnknown() { - xxx_messageInfo_IndexRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_IndexRequest proto.InternalMessageInfo - -func (m *IndexRequest) GetDocument() *Document { - if m != nil { - return m.Document - } - return nil -} - -type IndexResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *IndexResponse) Reset() { *m = IndexResponse{} } -func (m *IndexResponse) String() string { return proto.CompactTextString(m) } -func (*IndexResponse) ProtoMessage() {} -func (*IndexResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5c88c8197db8a717, []int{2} -} - -func (m *IndexResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_IndexResponse.Unmarshal(m, b) -} -func (m *IndexResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_IndexResponse.Marshal(b, m, deterministic) -} -func (m *IndexResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_IndexResponse.Merge(m, src) -} -func (m *IndexResponse) XXX_Size() int { - return xxx_messageInfo_IndexResponse.Size(m) -} -func (m *IndexResponse) XXX_DiscardUnknown() { - xxx_messageInfo_IndexResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_IndexResponse proto.InternalMessageInfo - -type SearchRequest struct { - Keyword string `protobuf:"bytes,1,opt,name=keyword,proto3" json:"keyword,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SearchRequest) Reset() { *m = SearchRequest{} } -func (m *SearchRequest) String() string { return proto.CompactTextString(m) } -func (*SearchRequest) ProtoMessage() {} -func (*SearchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5c88c8197db8a717, []int{3} -} - -func (m *SearchRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SearchRequest.Unmarshal(m, b) -} -func (m *SearchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SearchRequest.Marshal(b, m, deterministic) -} -func (m *SearchRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SearchRequest.Merge(m, src) -} -func (m *SearchRequest) XXX_Size() int { - return xxx_messageInfo_SearchRequest.Size(m) -} -func (m *SearchRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SearchRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SearchRequest proto.InternalMessageInfo - -func (m *SearchRequest) GetKeyword() string { - if m != nil { - return m.Keyword - } - return "" -} - -type SearchResponse struct { - Documents []*Document `protobuf:"bytes,1,rep,name=documents,proto3" json:"documents,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SearchResponse) Reset() { *m = SearchResponse{} } -func (m *SearchResponse) String() string { return proto.CompactTextString(m) } -func (*SearchResponse) ProtoMessage() {} -func (*SearchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5c88c8197db8a717, []int{4} -} - -func (m *SearchResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SearchResponse.Unmarshal(m, b) -} -func (m *SearchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SearchResponse.Marshal(b, m, deterministic) -} -func (m *SearchResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SearchResponse.Merge(m, src) -} -func (m *SearchResponse) XXX_Size() int { - return xxx_messageInfo_SearchResponse.Size(m) -} -func (m *SearchResponse) XXX_DiscardUnknown() { - xxx_messageInfo_SearchResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_SearchResponse proto.InternalMessageInfo - -func (m *SearchResponse) GetDocuments() []*Document { - if m != nil { - return m.Documents - } - return nil -} - -func init() { - proto.RegisterType((*Document)(nil), "search.Document") - proto.RegisterType((*IndexRequest)(nil), "search.IndexRequest") - proto.RegisterType((*IndexResponse)(nil), "search.IndexResponse") - proto.RegisterType((*SearchRequest)(nil), "search.SearchRequest") - proto.RegisterType((*SearchResponse)(nil), "search.SearchResponse") -} - -func init() { proto.RegisterFile("blog/search/proto/search.proto", fileDescriptor_5c88c8197db8a717) } - -var fileDescriptor_5c88c8197db8a717 = []byte{ - // 233 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xca, 0xc9, 0x4f, - 0xd7, 0x2f, 0x4e, 0x4d, 0x2c, 0x4a, 0xce, 0xd0, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x87, 0x72, 0xf4, - 0xc0, 0x1c, 0x21, 0x36, 0x08, 0x4f, 0x49, 0x8f, 0x8b, 0xc3, 0x25, 0x3f, 0xb9, 0x34, 0x37, 0x35, - 0xaf, 0x44, 0x88, 0x8f, 0x8b, 0x29, 0x33, 0x45, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x88, 0x29, - 0x33, 0x45, 0x48, 0x88, 0x8b, 0xa5, 0x24, 0xb5, 0xa2, 0x44, 0x82, 0x09, 0x2c, 0x02, 0x66, 0x2b, - 0xd9, 0x70, 0xf1, 0x78, 0xe6, 0xa5, 0xa4, 0x56, 0x04, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, - 0xe9, 0x70, 0x71, 0xa4, 0x40, 0xf5, 0x83, 0x75, 0x72, 0x1b, 0x09, 0xe8, 0x41, 0x2d, 0x82, 0x99, - 0x1b, 0x04, 0x57, 0xa1, 0xc4, 0xcf, 0xc5, 0x0b, 0xd5, 0x5d, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0xaa, - 0xa4, 0xc9, 0xc5, 0x1b, 0x0c, 0x56, 0x0d, 0x33, 0x4f, 0x82, 0x8b, 0x3d, 0x3b, 0xb5, 0xb2, 0x3c, - 0xbf, 0x08, 0xe6, 0x10, 0x18, 0x57, 0xc9, 0x81, 0x8b, 0x0f, 0xa6, 0x14, 0xa2, 0x59, 0x48, 0x8f, - 0x8b, 0x13, 0x66, 0x72, 0xb1, 0x04, 0xa3, 0x02, 0x33, 0x56, 0xcb, 0x11, 0x4a, 0x8c, 0xaa, 0xb9, - 0xd8, 0x20, 0x26, 0x08, 0x99, 0x71, 0xb1, 0x82, 0xdd, 0x21, 0x24, 0x02, 0x53, 0x8f, 0xec, 0x29, - 0x29, 0x51, 0x34, 0x51, 0xa8, 0x63, 0x19, 0x84, 0x2c, 0xe1, 0x26, 0xc0, 0x95, 0xa0, 0x38, 0x5f, - 0x4a, 0x0c, 0x5d, 0x18, 0xa6, 0x35, 0x89, 0x0d, 0x1c, 0xee, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x30, 0x86, 0x79, 0x74, 0x99, 0x01, 0x00, 0x00, -} diff --git a/blog/search/proto/search.pb.micro.go b/blog/search/proto/search.pb.micro.go deleted file mode 100644 index 07f0986..0000000 --- a/blog/search/proto/search.pb.micro.go +++ /dev/null @@ -1,110 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: blog/search/proto/search.proto - -package search - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -import ( - context "context" - api "github.com/micro/go-micro/v3/api" - client "github.com/micro/go-micro/v3/client" - server "github.com/micro/go-micro/v3/server" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint -var _ context.Context -var _ client.Option -var _ server.Option - -// Api Endpoints for Search service - -func NewSearchEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - -// Client API for Search service - -type SearchService interface { - Index(ctx context.Context, in *IndexRequest, opts ...client.CallOption) (*IndexResponse, error) - Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error) -} - -type searchService struct { - c client.Client - name string -} - -func NewSearchService(name string, c client.Client) SearchService { - return &searchService{ - c: c, - name: name, - } -} - -func (c *searchService) Index(ctx context.Context, in *IndexRequest, opts ...client.CallOption) (*IndexResponse, error) { - req := c.c.NewRequest(c.name, "Search.Index", in) - out := new(IndexResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *searchService) Search(ctx context.Context, in *SearchRequest, opts ...client.CallOption) (*SearchResponse, error) { - req := c.c.NewRequest(c.name, "Search.Search", in) - out := new(SearchResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Search service - -type SearchHandler interface { - Index(context.Context, *IndexRequest, *IndexResponse) error - Search(context.Context, *SearchRequest, *SearchResponse) error -} - -func RegisterSearchHandler(s server.Server, hdlr SearchHandler, opts ...server.HandlerOption) error { - type search interface { - Index(ctx context.Context, in *IndexRequest, out *IndexResponse) error - Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error - } - type Search struct { - search - } - h := &searchHandler{hdlr} - return s.Handle(s.NewHandler(&Search{h}, opts...)) -} - -type searchHandler struct { - SearchHandler -} - -func (h *searchHandler) Index(ctx context.Context, in *IndexRequest, out *IndexResponse) error { - return h.SearchHandler.Index(ctx, in, out) -} - -func (h *searchHandler) Search(ctx context.Context, in *SearchRequest, out *SearchResponse) error { - return h.SearchHandler.Search(ctx, in, out) -} diff --git a/blog/search/proto/search.proto b/blog/search/proto/search.proto deleted file mode 100644 index 57133e4..0000000 --- a/blog/search/proto/search.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; - -package search; - -service Search { - rpc Index(IndexRequest) returns (IndexResponse) {} - rpc Search(SearchRequest) returns (SearchResponse) {} -} - -message Document { - string id = 1; - string text = 2; -} - -message IndexRequest { - Document document = 1; -} - -message IndexResponse {} - -message SearchRequest { - string keyword = 1; -} - -message SearchResponse { - repeated Document documents = 1; -} \ No newline at end of file