feat: add test database setup and usage helpers
- Introduced a new test file for setting up an in-memory SQLite database for testing purposes. - Added helper functions for seeding test data, including users, plans, subscriptions, and wallet transactions. - Implemented usage helpers to load user video counts and storage usage. - Created user payload struct and functions to build user payloads with preferences and wallet balance. - Refactored gRPC server setup to include new services and handlers. - Updated proto files to simplify service definitions by removing redundant service prefixes.
This commit is contained in:
706
internal/api/proto/app/v1/account_grpc.pb.go
Normal file
706
internal/api/proto/app/v1/account_grpc.pb.go
Normal file
@@ -0,0 +1,706 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc (unknown)
|
||||
// source: app/v1/account.proto
|
||||
|
||||
package appv1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Account_GetMe_FullMethodName = "/stream.app.v1.Account/GetMe"
|
||||
Account_UpdateMe_FullMethodName = "/stream.app.v1.Account/UpdateMe"
|
||||
Account_DeleteMe_FullMethodName = "/stream.app.v1.Account/DeleteMe"
|
||||
Account_ClearMyData_FullMethodName = "/stream.app.v1.Account/ClearMyData"
|
||||
Account_GetUserById_FullMethodName = "/stream.app.v1.Account/GetUserById"
|
||||
Account_GetPreferences_FullMethodName = "/stream.app.v1.Account/GetPreferences"
|
||||
Account_UpdatePreferences_FullMethodName = "/stream.app.v1.Account/UpdatePreferences"
|
||||
)
|
||||
|
||||
// AccountClient is the client API for Account service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type AccountClient interface {
|
||||
GetMe(ctx context.Context, in *GetMeRequest, opts ...grpc.CallOption) (*GetMeResponse, error)
|
||||
UpdateMe(ctx context.Context, in *UpdateMeRequest, opts ...grpc.CallOption) (*UpdateMeResponse, error)
|
||||
DeleteMe(ctx context.Context, in *DeleteMeRequest, opts ...grpc.CallOption) (*MessageResponse, error)
|
||||
ClearMyData(ctx context.Context, in *ClearMyDataRequest, opts ...grpc.CallOption) (*MessageResponse, error)
|
||||
GetUserById(ctx context.Context, in *wrapperspb.StringValue, opts ...grpc.CallOption) (*User, error)
|
||||
GetPreferences(ctx context.Context, in *GetPreferencesRequest, opts ...grpc.CallOption) (*GetPreferencesResponse, error)
|
||||
UpdatePreferences(ctx context.Context, in *UpdatePreferencesRequest, opts ...grpc.CallOption) (*UpdatePreferencesResponse, error)
|
||||
}
|
||||
|
||||
type accountClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAccountClient(cc grpc.ClientConnInterface) AccountClient {
|
||||
return &accountClient{cc}
|
||||
}
|
||||
|
||||
func (c *accountClient) GetMe(ctx context.Context, in *GetMeRequest, opts ...grpc.CallOption) (*GetMeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetMeResponse)
|
||||
err := c.cc.Invoke(ctx, Account_GetMe_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *accountClient) UpdateMe(ctx context.Context, in *UpdateMeRequest, opts ...grpc.CallOption) (*UpdateMeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UpdateMeResponse)
|
||||
err := c.cc.Invoke(ctx, Account_UpdateMe_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *accountClient) DeleteMe(ctx context.Context, in *DeleteMeRequest, opts ...grpc.CallOption) (*MessageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MessageResponse)
|
||||
err := c.cc.Invoke(ctx, Account_DeleteMe_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *accountClient) ClearMyData(ctx context.Context, in *ClearMyDataRequest, opts ...grpc.CallOption) (*MessageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MessageResponse)
|
||||
err := c.cc.Invoke(ctx, Account_ClearMyData_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *accountClient) GetUserById(ctx context.Context, in *wrapperspb.StringValue, opts ...grpc.CallOption) (*User, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(User)
|
||||
err := c.cc.Invoke(ctx, Account_GetUserById_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *accountClient) GetPreferences(ctx context.Context, in *GetPreferencesRequest, opts ...grpc.CallOption) (*GetPreferencesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetPreferencesResponse)
|
||||
err := c.cc.Invoke(ctx, Account_GetPreferences_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *accountClient) UpdatePreferences(ctx context.Context, in *UpdatePreferencesRequest, opts ...grpc.CallOption) (*UpdatePreferencesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UpdatePreferencesResponse)
|
||||
err := c.cc.Invoke(ctx, Account_UpdatePreferences_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AccountServer is the server API for Account service.
|
||||
// All implementations must embed UnimplementedAccountServer
|
||||
// for forward compatibility.
|
||||
type AccountServer interface {
|
||||
GetMe(context.Context, *GetMeRequest) (*GetMeResponse, error)
|
||||
UpdateMe(context.Context, *UpdateMeRequest) (*UpdateMeResponse, error)
|
||||
DeleteMe(context.Context, *DeleteMeRequest) (*MessageResponse, error)
|
||||
ClearMyData(context.Context, *ClearMyDataRequest) (*MessageResponse, error)
|
||||
GetUserById(context.Context, *wrapperspb.StringValue) (*User, error)
|
||||
GetPreferences(context.Context, *GetPreferencesRequest) (*GetPreferencesResponse, error)
|
||||
UpdatePreferences(context.Context, *UpdatePreferencesRequest) (*UpdatePreferencesResponse, error)
|
||||
mustEmbedUnimplementedAccountServer()
|
||||
}
|
||||
|
||||
// UnimplementedAccountServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedAccountServer struct{}
|
||||
|
||||
func (UnimplementedAccountServer) GetMe(context.Context, *GetMeRequest) (*GetMeResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetMe not implemented")
|
||||
}
|
||||
func (UnimplementedAccountServer) UpdateMe(context.Context, *UpdateMeRequest) (*UpdateMeResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateMe not implemented")
|
||||
}
|
||||
func (UnimplementedAccountServer) DeleteMe(context.Context, *DeleteMeRequest) (*MessageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteMe not implemented")
|
||||
}
|
||||
func (UnimplementedAccountServer) ClearMyData(context.Context, *ClearMyDataRequest) (*MessageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ClearMyData not implemented")
|
||||
}
|
||||
func (UnimplementedAccountServer) GetUserById(context.Context, *wrapperspb.StringValue) (*User, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetUserById not implemented")
|
||||
}
|
||||
func (UnimplementedAccountServer) GetPreferences(context.Context, *GetPreferencesRequest) (*GetPreferencesResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetPreferences not implemented")
|
||||
}
|
||||
func (UnimplementedAccountServer) UpdatePreferences(context.Context, *UpdatePreferencesRequest) (*UpdatePreferencesResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdatePreferences not implemented")
|
||||
}
|
||||
func (UnimplementedAccountServer) mustEmbedUnimplementedAccountServer() {}
|
||||
func (UnimplementedAccountServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeAccountServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AccountServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAccountServer interface {
|
||||
mustEmbedUnimplementedAccountServer()
|
||||
}
|
||||
|
||||
func RegisterAccountServer(s grpc.ServiceRegistrar, srv AccountServer) {
|
||||
// If the following call panics, it indicates UnimplementedAccountServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Account_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Account_GetMe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountServer).GetMe(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Account_GetMe_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountServer).GetMe(ctx, req.(*GetMeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Account_UpdateMe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateMeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountServer).UpdateMe(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Account_UpdateMe_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountServer).UpdateMe(ctx, req.(*UpdateMeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Account_DeleteMe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteMeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountServer).DeleteMe(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Account_DeleteMe_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountServer).DeleteMe(ctx, req.(*DeleteMeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Account_ClearMyData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ClearMyDataRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountServer).ClearMyData(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Account_ClearMyData_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountServer).ClearMyData(ctx, req.(*ClearMyDataRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Account_GetUserById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(wrapperspb.StringValue)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountServer).GetUserById(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Account_GetUserById_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountServer).GetUserById(ctx, req.(*wrapperspb.StringValue))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Account_GetPreferences_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetPreferencesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountServer).GetPreferences(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Account_GetPreferences_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountServer).GetPreferences(ctx, req.(*GetPreferencesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Account_UpdatePreferences_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdatePreferencesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountServer).UpdatePreferences(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Account_UpdatePreferences_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountServer).UpdatePreferences(ctx, req.(*UpdatePreferencesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Account_ServiceDesc is the grpc.ServiceDesc for Account service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Account_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "stream.app.v1.Account",
|
||||
HandlerType: (*AccountServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetMe",
|
||||
Handler: _Account_GetMe_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateMe",
|
||||
Handler: _Account_UpdateMe_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteMe",
|
||||
Handler: _Account_DeleteMe_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ClearMyData",
|
||||
Handler: _Account_ClearMyData_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetUserById",
|
||||
Handler: _Account_GetUserById_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetPreferences",
|
||||
Handler: _Account_GetPreferences_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdatePreferences",
|
||||
Handler: _Account_UpdatePreferences_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "app/v1/account.proto",
|
||||
}
|
||||
|
||||
const (
|
||||
Usage_GetUsage_FullMethodName = "/stream.app.v1.Usage/GetUsage"
|
||||
)
|
||||
|
||||
// UsageClient is the client API for Usage service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type UsageClient interface {
|
||||
GetUsage(ctx context.Context, in *GetUsageRequest, opts ...grpc.CallOption) (*GetUsageResponse, error)
|
||||
}
|
||||
|
||||
type usageClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewUsageClient(cc grpc.ClientConnInterface) UsageClient {
|
||||
return &usageClient{cc}
|
||||
}
|
||||
|
||||
func (c *usageClient) GetUsage(ctx context.Context, in *GetUsageRequest, opts ...grpc.CallOption) (*GetUsageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetUsageResponse)
|
||||
err := c.cc.Invoke(ctx, Usage_GetUsage_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// UsageServer is the server API for Usage service.
|
||||
// All implementations must embed UnimplementedUsageServer
|
||||
// for forward compatibility.
|
||||
type UsageServer interface {
|
||||
GetUsage(context.Context, *GetUsageRequest) (*GetUsageResponse, error)
|
||||
mustEmbedUnimplementedUsageServer()
|
||||
}
|
||||
|
||||
// UnimplementedUsageServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedUsageServer struct{}
|
||||
|
||||
func (UnimplementedUsageServer) GetUsage(context.Context, *GetUsageRequest) (*GetUsageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetUsage not implemented")
|
||||
}
|
||||
func (UnimplementedUsageServer) mustEmbedUnimplementedUsageServer() {}
|
||||
func (UnimplementedUsageServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeUsageServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to UsageServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeUsageServer interface {
|
||||
mustEmbedUnimplementedUsageServer()
|
||||
}
|
||||
|
||||
func RegisterUsageServer(s grpc.ServiceRegistrar, srv UsageServer) {
|
||||
// If the following call panics, it indicates UnimplementedUsageServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Usage_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Usage_GetUsage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUsageRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UsageServer).GetUsage(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Usage_GetUsage_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UsageServer).GetUsage(ctx, req.(*GetUsageRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Usage_ServiceDesc is the grpc.ServiceDesc for Usage service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Usage_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "stream.app.v1.Usage",
|
||||
HandlerType: (*UsageServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetUsage",
|
||||
Handler: _Usage_GetUsage_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "app/v1/account.proto",
|
||||
}
|
||||
|
||||
const (
|
||||
Notifications_ListNotifications_FullMethodName = "/stream.app.v1.Notifications/ListNotifications"
|
||||
Notifications_MarkNotificationRead_FullMethodName = "/stream.app.v1.Notifications/MarkNotificationRead"
|
||||
Notifications_MarkAllNotificationsRead_FullMethodName = "/stream.app.v1.Notifications/MarkAllNotificationsRead"
|
||||
Notifications_DeleteNotification_FullMethodName = "/stream.app.v1.Notifications/DeleteNotification"
|
||||
Notifications_ClearNotifications_FullMethodName = "/stream.app.v1.Notifications/ClearNotifications"
|
||||
)
|
||||
|
||||
// NotificationsClient is the client API for Notifications service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type NotificationsClient interface {
|
||||
ListNotifications(ctx context.Context, in *ListNotificationsRequest, opts ...grpc.CallOption) (*ListNotificationsResponse, error)
|
||||
MarkNotificationRead(ctx context.Context, in *MarkNotificationReadRequest, opts ...grpc.CallOption) (*MessageResponse, error)
|
||||
MarkAllNotificationsRead(ctx context.Context, in *MarkAllNotificationsReadRequest, opts ...grpc.CallOption) (*MessageResponse, error)
|
||||
DeleteNotification(ctx context.Context, in *DeleteNotificationRequest, opts ...grpc.CallOption) (*MessageResponse, error)
|
||||
ClearNotifications(ctx context.Context, in *ClearNotificationsRequest, opts ...grpc.CallOption) (*MessageResponse, error)
|
||||
}
|
||||
|
||||
type notificationsClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewNotificationsClient(cc grpc.ClientConnInterface) NotificationsClient {
|
||||
return ¬ificationsClient{cc}
|
||||
}
|
||||
|
||||
func (c *notificationsClient) ListNotifications(ctx context.Context, in *ListNotificationsRequest, opts ...grpc.CallOption) (*ListNotificationsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListNotificationsResponse)
|
||||
err := c.cc.Invoke(ctx, Notifications_ListNotifications_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *notificationsClient) MarkNotificationRead(ctx context.Context, in *MarkNotificationReadRequest, opts ...grpc.CallOption) (*MessageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MessageResponse)
|
||||
err := c.cc.Invoke(ctx, Notifications_MarkNotificationRead_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *notificationsClient) MarkAllNotificationsRead(ctx context.Context, in *MarkAllNotificationsReadRequest, opts ...grpc.CallOption) (*MessageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MessageResponse)
|
||||
err := c.cc.Invoke(ctx, Notifications_MarkAllNotificationsRead_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *notificationsClient) DeleteNotification(ctx context.Context, in *DeleteNotificationRequest, opts ...grpc.CallOption) (*MessageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MessageResponse)
|
||||
err := c.cc.Invoke(ctx, Notifications_DeleteNotification_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *notificationsClient) ClearNotifications(ctx context.Context, in *ClearNotificationsRequest, opts ...grpc.CallOption) (*MessageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MessageResponse)
|
||||
err := c.cc.Invoke(ctx, Notifications_ClearNotifications_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// NotificationsServer is the server API for Notifications service.
|
||||
// All implementations must embed UnimplementedNotificationsServer
|
||||
// for forward compatibility.
|
||||
type NotificationsServer interface {
|
||||
ListNotifications(context.Context, *ListNotificationsRequest) (*ListNotificationsResponse, error)
|
||||
MarkNotificationRead(context.Context, *MarkNotificationReadRequest) (*MessageResponse, error)
|
||||
MarkAllNotificationsRead(context.Context, *MarkAllNotificationsReadRequest) (*MessageResponse, error)
|
||||
DeleteNotification(context.Context, *DeleteNotificationRequest) (*MessageResponse, error)
|
||||
ClearNotifications(context.Context, *ClearNotificationsRequest) (*MessageResponse, error)
|
||||
mustEmbedUnimplementedNotificationsServer()
|
||||
}
|
||||
|
||||
// UnimplementedNotificationsServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedNotificationsServer struct{}
|
||||
|
||||
func (UnimplementedNotificationsServer) ListNotifications(context.Context, *ListNotificationsRequest) (*ListNotificationsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListNotifications not implemented")
|
||||
}
|
||||
func (UnimplementedNotificationsServer) MarkNotificationRead(context.Context, *MarkNotificationReadRequest) (*MessageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method MarkNotificationRead not implemented")
|
||||
}
|
||||
func (UnimplementedNotificationsServer) MarkAllNotificationsRead(context.Context, *MarkAllNotificationsReadRequest) (*MessageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method MarkAllNotificationsRead not implemented")
|
||||
}
|
||||
func (UnimplementedNotificationsServer) DeleteNotification(context.Context, *DeleteNotificationRequest) (*MessageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteNotification not implemented")
|
||||
}
|
||||
func (UnimplementedNotificationsServer) ClearNotifications(context.Context, *ClearNotificationsRequest) (*MessageResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ClearNotifications not implemented")
|
||||
}
|
||||
func (UnimplementedNotificationsServer) mustEmbedUnimplementedNotificationsServer() {}
|
||||
func (UnimplementedNotificationsServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeNotificationsServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to NotificationsServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeNotificationsServer interface {
|
||||
mustEmbedUnimplementedNotificationsServer()
|
||||
}
|
||||
|
||||
func RegisterNotificationsServer(s grpc.ServiceRegistrar, srv NotificationsServer) {
|
||||
// If the following call panics, it indicates UnimplementedNotificationsServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Notifications_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Notifications_ListNotifications_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListNotificationsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NotificationsServer).ListNotifications(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Notifications_ListNotifications_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NotificationsServer).ListNotifications(ctx, req.(*ListNotificationsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Notifications_MarkNotificationRead_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MarkNotificationReadRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NotificationsServer).MarkNotificationRead(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Notifications_MarkNotificationRead_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NotificationsServer).MarkNotificationRead(ctx, req.(*MarkNotificationReadRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Notifications_MarkAllNotificationsRead_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MarkAllNotificationsReadRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NotificationsServer).MarkAllNotificationsRead(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Notifications_MarkAllNotificationsRead_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NotificationsServer).MarkAllNotificationsRead(ctx, req.(*MarkAllNotificationsReadRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Notifications_DeleteNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteNotificationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NotificationsServer).DeleteNotification(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Notifications_DeleteNotification_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NotificationsServer).DeleteNotification(ctx, req.(*DeleteNotificationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Notifications_ClearNotifications_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ClearNotificationsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NotificationsServer).ClearNotifications(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Notifications_ClearNotifications_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NotificationsServer).ClearNotifications(ctx, req.(*ClearNotificationsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Notifications_ServiceDesc is the grpc.ServiceDesc for Notifications service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Notifications_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "stream.app.v1.Notifications",
|
||||
HandlerType: (*NotificationsServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "ListNotifications",
|
||||
Handler: _Notifications_ListNotifications_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "MarkNotificationRead",
|
||||
Handler: _Notifications_MarkNotificationRead_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "MarkAllNotificationsRead",
|
||||
Handler: _Notifications_MarkAllNotificationsRead_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteNotification",
|
||||
Handler: _Notifications_DeleteNotification_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ClearNotifications",
|
||||
Handler: _Notifications_ClearNotifications_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "app/v1/account.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user