// Code generated by protoc-gen-micro. DO NOT EDIT. // source: user.proto package user import ( fmt "fmt" proto "google.golang.org/protobuf/proto" math "math" ) import ( context "context" client "go-micro.dev/v5/client" server "go-micro.dev/v5/server" model "go-micro.dev/v5/model" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf // Reference imports to suppress errors if they are not otherwise used. var _ context.Context var _ client.Option var _ server.Option var _ model.Model // Client API for UserService service type UserServiceService interface { Create(ctx context.Context, in *CreateUserRequest, opts ...client.CallOption) (*CreateUserResponse, error) Get(ctx context.Context, in *GetUserRequest, opts ...client.CallOption) (*GetUserResponse, error) Delete(ctx context.Context, in *DeleteUserRequest, opts ...client.CallOption) (*DeleteUserResponse, error) } type userServiceService struct { c client.Client name string } func NewUserServiceService(name string, c client.Client) UserServiceService { return &userServiceService{ c: c, name: name, } } func (c *userServiceService) Create(ctx context.Context, in *CreateUserRequest, opts ...client.CallOption) (*CreateUserResponse, error) { req := c.c.NewRequest(c.name, "UserService.Create", in) out := new(CreateUserResponse) err := c.c.Call(ctx, req, out, opts...) if err != nil { return nil, err } return out, nil } func (c *userServiceService) Get(ctx context.Context, in *GetUserRequest, opts ...client.CallOption) (*GetUserResponse, error) { req := c.c.NewRequest(c.name, "UserService.Get", in) out := new(GetUserResponse) err := c.c.Call(ctx, req, out, opts...) if err != nil { return nil, err } return out, nil } func (c *userServiceService) Delete(ctx context.Context, in *DeleteUserRequest, opts ...client.CallOption) (*DeleteUserResponse, error) { req := c.c.NewRequest(c.name, "UserService.Delete", in) out := new(DeleteUserResponse) err := c.c.Call(ctx, req, out, opts...) if err != nil { return nil, err } return out, nil } // Server API for UserService service type UserServiceHandler interface { Create(context.Context, *CreateUserRequest, *CreateUserResponse) error Get(context.Context, *GetUserRequest, *GetUserResponse) error Delete(context.Context, *DeleteUserRequest, *DeleteUserResponse) error } func RegisterUserServiceHandler(s server.Server, hdlr UserServiceHandler, opts ...server.HandlerOption) error { type userService interface { Create(ctx context.Context, in *CreateUserRequest, out *CreateUserResponse) error Get(ctx context.Context, in *GetUserRequest, out *GetUserResponse) error Delete(ctx context.Context, in *DeleteUserRequest, out *DeleteUserResponse) error } type UserService struct { userService } h := &userServiceHandler{hdlr} return s.Handle(s.NewHandler(&UserService{h}, opts...)) } type userServiceHandler struct { UserServiceHandler } func (h *userServiceHandler) Create(ctx context.Context, in *CreateUserRequest, out *CreateUserResponse) error { return h.UserServiceHandler.Create(ctx, in, out) } func (h *userServiceHandler) Get(ctx context.Context, in *GetUserRequest, out *GetUserResponse) error { return h.UserServiceHandler.Get(ctx, in, out) } func (h *userServiceHandler) Delete(ctx context.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { return h.UserServiceHandler.Delete(ctx, in, out) } // UserModel is a model struct generated from User. // Use NewUserModel to create a typed table backed by any model.Model. type UserModel struct { Id string `json:"id" model:"key"` Name string `json:"name"` Email string `json:"email"` Age int32 `json:"age"` Status string `json:"status"` } // RegisterUserModel registers the UserModel table with the given model backend. func RegisterUserModel(db model.Model) error { return db.Register(&UserModel{}, model.WithTable("users")) } // UserModelFromProto converts a User proto message to a UserModel. func UserModelFromProto(p *User) *UserModel { if p == nil { return nil } return &UserModel{ Id: p.GetId(), Name: p.GetName(), Email: p.GetEmail(), Age: p.GetAge(), Status: p.GetStatus(), } } // ToProto converts a UserModel to a User proto message. func (m *UserModel) ToProto() *User { if m == nil { return nil } return &User{ Id: m.Id, Name: m.Name, Email: m.Email, Age: m.Age, Status: m.Status, } }