- 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.
312 lines
12 KiB
Go
312 lines
12 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.6.1
|
|
// - protoc (unknown)
|
|
// source: app/v1/videos.proto
|
|
|
|
package appv1
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// 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 (
|
|
Videos_GetUploadUrl_FullMethodName = "/stream.app.v1.Videos/GetUploadUrl"
|
|
Videos_CreateVideo_FullMethodName = "/stream.app.v1.Videos/CreateVideo"
|
|
Videos_ListVideos_FullMethodName = "/stream.app.v1.Videos/ListVideos"
|
|
Videos_GetVideo_FullMethodName = "/stream.app.v1.Videos/GetVideo"
|
|
Videos_UpdateVideo_FullMethodName = "/stream.app.v1.Videos/UpdateVideo"
|
|
Videos_DeleteVideo_FullMethodName = "/stream.app.v1.Videos/DeleteVideo"
|
|
)
|
|
|
|
// VideosClient is the client API for Videos 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 VideosClient interface {
|
|
GetUploadUrl(ctx context.Context, in *GetUploadUrlRequest, opts ...grpc.CallOption) (*GetUploadUrlResponse, error)
|
|
CreateVideo(ctx context.Context, in *CreateVideoRequest, opts ...grpc.CallOption) (*CreateVideoResponse, error)
|
|
ListVideos(ctx context.Context, in *ListVideosRequest, opts ...grpc.CallOption) (*ListVideosResponse, error)
|
|
GetVideo(ctx context.Context, in *GetVideoRequest, opts ...grpc.CallOption) (*GetVideoResponse, error)
|
|
UpdateVideo(ctx context.Context, in *UpdateVideoRequest, opts ...grpc.CallOption) (*UpdateVideoResponse, error)
|
|
DeleteVideo(ctx context.Context, in *DeleteVideoRequest, opts ...grpc.CallOption) (*MessageResponse, error)
|
|
}
|
|
|
|
type videosClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewVideosClient(cc grpc.ClientConnInterface) VideosClient {
|
|
return &videosClient{cc}
|
|
}
|
|
|
|
func (c *videosClient) GetUploadUrl(ctx context.Context, in *GetUploadUrlRequest, opts ...grpc.CallOption) (*GetUploadUrlResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(GetUploadUrlResponse)
|
|
err := c.cc.Invoke(ctx, Videos_GetUploadUrl_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *videosClient) CreateVideo(ctx context.Context, in *CreateVideoRequest, opts ...grpc.CallOption) (*CreateVideoResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(CreateVideoResponse)
|
|
err := c.cc.Invoke(ctx, Videos_CreateVideo_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *videosClient) ListVideos(ctx context.Context, in *ListVideosRequest, opts ...grpc.CallOption) (*ListVideosResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(ListVideosResponse)
|
|
err := c.cc.Invoke(ctx, Videos_ListVideos_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *videosClient) GetVideo(ctx context.Context, in *GetVideoRequest, opts ...grpc.CallOption) (*GetVideoResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(GetVideoResponse)
|
|
err := c.cc.Invoke(ctx, Videos_GetVideo_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *videosClient) UpdateVideo(ctx context.Context, in *UpdateVideoRequest, opts ...grpc.CallOption) (*UpdateVideoResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(UpdateVideoResponse)
|
|
err := c.cc.Invoke(ctx, Videos_UpdateVideo_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *videosClient) DeleteVideo(ctx context.Context, in *DeleteVideoRequest, opts ...grpc.CallOption) (*MessageResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(MessageResponse)
|
|
err := c.cc.Invoke(ctx, Videos_DeleteVideo_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// VideosServer is the server API for Videos service.
|
|
// All implementations must embed UnimplementedVideosServer
|
|
// for forward compatibility.
|
|
type VideosServer interface {
|
|
GetUploadUrl(context.Context, *GetUploadUrlRequest) (*GetUploadUrlResponse, error)
|
|
CreateVideo(context.Context, *CreateVideoRequest) (*CreateVideoResponse, error)
|
|
ListVideos(context.Context, *ListVideosRequest) (*ListVideosResponse, error)
|
|
GetVideo(context.Context, *GetVideoRequest) (*GetVideoResponse, error)
|
|
UpdateVideo(context.Context, *UpdateVideoRequest) (*UpdateVideoResponse, error)
|
|
DeleteVideo(context.Context, *DeleteVideoRequest) (*MessageResponse, error)
|
|
mustEmbedUnimplementedVideosServer()
|
|
}
|
|
|
|
// UnimplementedVideosServer 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 UnimplementedVideosServer struct{}
|
|
|
|
func (UnimplementedVideosServer) GetUploadUrl(context.Context, *GetUploadUrlRequest) (*GetUploadUrlResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method GetUploadUrl not implemented")
|
|
}
|
|
func (UnimplementedVideosServer) CreateVideo(context.Context, *CreateVideoRequest) (*CreateVideoResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method CreateVideo not implemented")
|
|
}
|
|
func (UnimplementedVideosServer) ListVideos(context.Context, *ListVideosRequest) (*ListVideosResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method ListVideos not implemented")
|
|
}
|
|
func (UnimplementedVideosServer) GetVideo(context.Context, *GetVideoRequest) (*GetVideoResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method GetVideo not implemented")
|
|
}
|
|
func (UnimplementedVideosServer) UpdateVideo(context.Context, *UpdateVideoRequest) (*UpdateVideoResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method UpdateVideo not implemented")
|
|
}
|
|
func (UnimplementedVideosServer) DeleteVideo(context.Context, *DeleteVideoRequest) (*MessageResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "method DeleteVideo not implemented")
|
|
}
|
|
func (UnimplementedVideosServer) mustEmbedUnimplementedVideosServer() {}
|
|
func (UnimplementedVideosServer) testEmbeddedByValue() {}
|
|
|
|
// UnsafeVideosServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to VideosServer will
|
|
// result in compilation errors.
|
|
type UnsafeVideosServer interface {
|
|
mustEmbedUnimplementedVideosServer()
|
|
}
|
|
|
|
func RegisterVideosServer(s grpc.ServiceRegistrar, srv VideosServer) {
|
|
// If the following call panics, it indicates UnimplementedVideosServer 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(&Videos_ServiceDesc, srv)
|
|
}
|
|
|
|
func _Videos_GetUploadUrl_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(GetUploadUrlRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(VideosServer).GetUploadUrl(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Videos_GetUploadUrl_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(VideosServer).GetUploadUrl(ctx, req.(*GetUploadUrlRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Videos_CreateVideo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(CreateVideoRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(VideosServer).CreateVideo(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Videos_CreateVideo_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(VideosServer).CreateVideo(ctx, req.(*CreateVideoRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Videos_ListVideos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(ListVideosRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(VideosServer).ListVideos(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Videos_ListVideos_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(VideosServer).ListVideos(ctx, req.(*ListVideosRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Videos_GetVideo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(GetVideoRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(VideosServer).GetVideo(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Videos_GetVideo_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(VideosServer).GetVideo(ctx, req.(*GetVideoRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Videos_UpdateVideo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(UpdateVideoRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(VideosServer).UpdateVideo(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Videos_UpdateVideo_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(VideosServer).UpdateVideo(ctx, req.(*UpdateVideoRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Videos_DeleteVideo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(DeleteVideoRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(VideosServer).DeleteVideo(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Videos_DeleteVideo_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(VideosServer).DeleteVideo(ctx, req.(*DeleteVideoRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
// Videos_ServiceDesc is the grpc.ServiceDesc for Videos service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var Videos_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "stream.app.v1.Videos",
|
|
HandlerType: (*VideosServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{
|
|
MethodName: "GetUploadUrl",
|
|
Handler: _Videos_GetUploadUrl_Handler,
|
|
},
|
|
{
|
|
MethodName: "CreateVideo",
|
|
Handler: _Videos_CreateVideo_Handler,
|
|
},
|
|
{
|
|
MethodName: "ListVideos",
|
|
Handler: _Videos_ListVideos_Handler,
|
|
},
|
|
{
|
|
MethodName: "GetVideo",
|
|
Handler: _Videos_GetVideo_Handler,
|
|
},
|
|
{
|
|
MethodName: "UpdateVideo",
|
|
Handler: _Videos_UpdateVideo_Handler,
|
|
},
|
|
{
|
|
MethodName: "DeleteVideo",
|
|
Handler: _Videos_DeleteVideo_Handler,
|
|
},
|
|
},
|
|
Streams: []grpc.StreamDesc{},
|
|
Metadata: "app/v1/videos.proto",
|
|
}
|