add notes (#218)

* add notes

* fix build

* Commit from GitHub Actions (Publish APIs & Clients)

Co-authored-by: asim <asim@users.noreply.github.com>
This commit is contained in:
Asim Aslam
2021-09-29 14:02:28 +01:00
committed by GitHub
parent 29aea04423
commit 3c38d96881
29 changed files with 2223 additions and 1 deletions

1002
notes/proto/notes.pb.go Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,253 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/notes.proto
package notes
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
api "github.com/micro/micro/v3/service/api"
client "github.com/micro/micro/v3/service/client"
server "github.com/micro/micro/v3/service/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 Notes service
func NewNotesEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for Notes service
type NotesService interface {
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error)
Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error)
Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error)
Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error)
Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Notes_SubscribeService, error)
}
type notesService struct {
c client.Client
name string
}
func NewNotesService(name string, c client.Client) NotesService {
return &notesService{
c: c,
name: name,
}
}
func (c *notesService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Notes.List", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notesService) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) {
req := c.c.NewRequest(c.name, "Notes.Create", in)
out := new(CreateResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notesService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) {
req := c.c.NewRequest(c.name, "Notes.Read", in)
out := new(ReadResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notesService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) {
req := c.c.NewRequest(c.name, "Notes.Delete", in)
out := new(DeleteResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notesService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) {
req := c.c.NewRequest(c.name, "Notes.Update", in)
out := new(UpdateResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notesService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Notes_SubscribeService, error) {
req := c.c.NewRequest(c.name, "Notes.Subscribe", &SubscribeRequest{})
stream, err := c.c.Stream(ctx, req, opts...)
if err != nil {
return nil, err
}
if err := stream.Send(in); err != nil {
return nil, err
}
return &notesServiceSubscribe{stream}, nil
}
type Notes_SubscribeService interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*SubscribeResponse, error)
}
type notesServiceSubscribe struct {
stream client.Stream
}
func (x *notesServiceSubscribe) Close() error {
return x.stream.Close()
}
func (x *notesServiceSubscribe) Context() context.Context {
return x.stream.Context()
}
func (x *notesServiceSubscribe) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *notesServiceSubscribe) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *notesServiceSubscribe) Recv() (*SubscribeResponse, error) {
m := new(SubscribeResponse)
err := x.stream.Recv(m)
if err != nil {
return nil, err
}
return m, nil
}
// Server API for Notes service
type NotesHandler interface {
List(context.Context, *ListRequest, *ListResponse) error
Create(context.Context, *CreateRequest, *CreateResponse) error
Read(context.Context, *ReadRequest, *ReadResponse) error
Delete(context.Context, *DeleteRequest, *DeleteResponse) error
Update(context.Context, *UpdateRequest, *UpdateResponse) error
Subscribe(context.Context, *SubscribeRequest, Notes_SubscribeStream) error
}
func RegisterNotesHandler(s server.Server, hdlr NotesHandler, opts ...server.HandlerOption) error {
type notes interface {
List(ctx context.Context, in *ListRequest, out *ListResponse) error
Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error
Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error
Subscribe(ctx context.Context, stream server.Stream) error
}
type Notes struct {
notes
}
h := &notesHandler{hdlr}
return s.Handle(s.NewHandler(&Notes{h}, opts...))
}
type notesHandler struct {
NotesHandler
}
func (h *notesHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.NotesHandler.List(ctx, in, out)
}
func (h *notesHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error {
return h.NotesHandler.Create(ctx, in, out)
}
func (h *notesHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error {
return h.NotesHandler.Read(ctx, in, out)
}
func (h *notesHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error {
return h.NotesHandler.Delete(ctx, in, out)
}
func (h *notesHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error {
return h.NotesHandler.Update(ctx, in, out)
}
func (h *notesHandler) Subscribe(ctx context.Context, stream server.Stream) error {
m := new(SubscribeRequest)
if err := stream.Recv(m); err != nil {
return err
}
return h.NotesHandler.Subscribe(ctx, m, &notesSubscribeStream{stream})
}
type Notes_SubscribeStream interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*SubscribeResponse) error
}
type notesSubscribeStream struct {
stream server.Stream
}
func (x *notesSubscribeStream) Close() error {
return x.stream.Close()
}
func (x *notesSubscribeStream) Context() context.Context {
return x.stream.Context()
}
func (x *notesSubscribeStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *notesSubscribeStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *notesSubscribeStream) Send(m *SubscribeResponse) error {
return x.stream.Send(m)
}

91
notes/proto/notes.proto Normal file
View File

@@ -0,0 +1,91 @@
syntax = "proto3";
package notes;
option go_package = "./proto;notes";
service Notes {
rpc List(ListRequest) returns (ListResponse);
rpc Create(CreateRequest) returns (CreateResponse);
rpc Read(ReadRequest) returns (ReadResponse);
rpc Delete(DeleteRequest) returns (DeleteResponse);
rpc Update(UpdateRequest) returns (UpdateResponse);
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse);
}
message Note {
// unique id for the note, generated if not specified
string id = 1;
// time at which the note was created
string created = 2;
// time at which the note was updated
string updated = 3;
// title of the note
string title = 4;
// text within the note
string text = 5;
}
// Create a new note
message CreateRequest {
// note title
string title = 1;
// note text
string text = 2;
}
message CreateResponse {
// The created note
Note note = 1;
}
// Read a note
message ReadRequest {
// the note id
string id = 1;
}
message ReadResponse {
// The note
Note note = 1;
}
// Update a note
message UpdateRequest {
Note note = 1;
}
message UpdateResponse {
Note note = 1;
}
// Delete a note
message DeleteRequest {
// specify the id of the note
string id = 1;
}
message DeleteResponse {
Note note = 1;
}
// List all the notes
message ListRequest {}
message ListResponse {
// the list of notes
repeated Note notes = 1;
}
// Specify the note to events
message SubscribeRequest {
// optionally specify a note id
string id = 1;
}
message SubscribeResponse {
// the event which occured; created, deleted, updated
string event = 1;
// the note which the operation occured on
Note note = 2;
}