service

package
v0.0.0-...-3dd2d23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Role_name = map[int32]string{
		0: "USER",
		1: "ADMIN",
	}
	Role_value = map[string]int32{
		"USER":  0,
		"ADMIN": 1,
	}
)

Enum value maps for Role.

View Source
var Consensus_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "service.Consensus",
	HandlerType: (*ConsensusServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateUser",
			Handler:    _Consensus_CreateUser_Handler,
		},
		{
			MethodName: "GetUsers",
			Handler:    _Consensus_GetUsers_Handler,
		},
		{
			MethodName: "AuthenticateUser",
			Handler:    _Consensus_AuthenticateUser_Handler,
		},
		{
			MethodName: "CreateProject",
			Handler:    _Consensus_CreateProject_Handler,
		},
		{
			MethodName: "GetProjects",
			Handler:    _Consensus_GetProjects_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "service.proto",
}

Consensus_ServiceDesc is the grpc.ServiceDesc for Consensus service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_service_proto protoreflect.FileDescriptor

Functions

func RegisterConsensusServer

func RegisterConsensusServer(s grpc.ServiceRegistrar, srv ConsensusServer)

Types

type AuthReq

type AuthReq struct {

	// email is the email address of the user.
	Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
	// password is the password of the user.
	Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	// contains filtered or unexported fields
}

AuthReq is the request for authentication.

func (*AuthReq) Descriptor deprecated

func (*AuthReq) Descriptor() ([]byte, []int)

Deprecated: Use AuthReq.ProtoReflect.Descriptor instead.

func (*AuthReq) GetEmail

func (x *AuthReq) GetEmail() string

func (*AuthReq) GetPassword

func (x *AuthReq) GetPassword() string

func (*AuthReq) ProtoMessage

func (*AuthReq) ProtoMessage()

func (*AuthReq) ProtoReflect

func (x *AuthReq) ProtoReflect() protoreflect.Message

func (*AuthReq) Reset

func (x *AuthReq) Reset()

func (*AuthReq) String

func (x *AuthReq) String() string

type ConsensusClient

type ConsensusClient interface {
	// CreateUser creates a new user.
	CreateUser(ctx context.Context, in *User, opts ...grpc.CallOption) (*User, error)
	// GetUsers returns all the existing users.
	GetUsers(ctx context.Context, in *GetUsersReq, opts ...grpc.CallOption) (*Users, error)
	// AuthenticateUser authenticates a user.
	AuthenticateUser(ctx context.Context, in *AuthReq, opts ...grpc.CallOption) (*User, error)
	// CreateProject creates a new project.
	CreateProject(ctx context.Context, in *Project, opts ...grpc.CallOption) (*Project, error)
	// GetProjects returns all the existing projects.
	GetProjects(ctx context.Context, in *ProjectsReq, opts ...grpc.CallOption) (*Projects, error)
}

ConsensusClient is the client API for Consensus 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.

func NewConsensusClient

func NewConsensusClient(cc grpc.ClientConnInterface) ConsensusClient

type ConsensusServer

type ConsensusServer interface {
	// CreateUser creates a new user.
	CreateUser(context.Context, *User) (*User, error)
	// GetUsers returns all the existing users.
	GetUsers(context.Context, *GetUsersReq) (*Users, error)
	// AuthenticateUser authenticates a user.
	AuthenticateUser(context.Context, *AuthReq) (*User, error)
	// CreateProject creates a new project.
	CreateProject(context.Context, *Project) (*Project, error)
	// GetProjects returns all the existing projects.
	GetProjects(context.Context, *ProjectsReq) (*Projects, error)
	// contains filtered or unexported methods
}

ConsensusServer is the server API for Consensus service. All implementations must embed UnimplementedConsensusServer for forward compatibility

type GetUsersReq

type GetUsersReq struct {
	// contains filtered or unexported fields
}

GetUsersReq is the request for fetching existing users.

func (*GetUsersReq) Descriptor deprecated

func (*GetUsersReq) Descriptor() ([]byte, []int)

Deprecated: Use GetUsersReq.ProtoReflect.Descriptor instead.

func (*GetUsersReq) ProtoMessage

func (*GetUsersReq) ProtoMessage()

func (*GetUsersReq) ProtoReflect

func (x *GetUsersReq) ProtoReflect() protoreflect.Message

func (*GetUsersReq) Reset

func (x *GetUsersReq) Reset()

func (*GetUsersReq) String

func (x *GetUsersReq) String() string

type Project

type Project struct {

	// id is the unique identifier of the project.
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// created_at is the timestamp when the project was created.
	CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// updated_at is the timestamp when the project was last updated.
	UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// name is the name of the project.
	Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"`
	// description is the description of the project.
	Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"`
	// owner is the owner of the project.
	Owner *User `protobuf:"bytes,6,opt,name=owner,proto3" json:"owner,omitempty"`
	// contains filtered or unexported fields
}

Project represents a single project.

func DBProjectToCoreProject

func DBProjectToCoreProject(project client.Project) *Project

DBProjectToCoreProject converts a database project to a core project.

func DBProjectsToCoreProjects

func DBProjectsToCoreProjects(projects ...client.Project) []*Project

DBProjectsToCoreProjects converts a one or more database projects to one or more core projects.

func (*Project) Descriptor deprecated

func (*Project) Descriptor() ([]byte, []int)

Deprecated: Use Project.ProtoReflect.Descriptor instead.

func (*Project) GetCreatedAt

func (x *Project) GetCreatedAt() *timestamppb.Timestamp

func (*Project) GetDescription

func (x *Project) GetDescription() string

func (*Project) GetId

func (x *Project) GetId() int64

func (*Project) GetName

func (x *Project) GetName() string

func (*Project) GetOwner

func (x *Project) GetOwner() *User

func (*Project) GetUpdatedAt

func (x *Project) GetUpdatedAt() *timestamppb.Timestamp

func (*Project) ProtoMessage

func (*Project) ProtoMessage()

func (*Project) ProtoReflect

func (x *Project) ProtoReflect() protoreflect.Message

func (*Project) Reset

func (x *Project) Reset()

func (*Project) String

func (x *Project) String() string

type Projects

type Projects struct {

	// projects is the list of projects.
	Projects []*Project `protobuf:"bytes,1,rep,name=projects,proto3" json:"projects,omitempty"`
	// contains filtered or unexported fields
}

ProjectsResp is the response containing all the existing projects.

func (*Projects) Descriptor deprecated

func (*Projects) Descriptor() ([]byte, []int)

Deprecated: Use Projects.ProtoReflect.Descriptor instead.

func (*Projects) GetProjects

func (x *Projects) GetProjects() []*Project

func (*Projects) ProtoMessage

func (*Projects) ProtoMessage()

func (*Projects) ProtoReflect

func (x *Projects) ProtoReflect() protoreflect.Message

func (*Projects) Reset

func (x *Projects) Reset()

func (*Projects) String

func (x *Projects) String() string

type ProjectsReq

type ProjectsReq struct {
	// contains filtered or unexported fields
}

ProjectsReq is the request for fetching existing projects.

func (*ProjectsReq) Descriptor deprecated

func (*ProjectsReq) Descriptor() ([]byte, []int)

Deprecated: Use ProjectsReq.ProtoReflect.Descriptor instead.

func (*ProjectsReq) ProtoMessage

func (*ProjectsReq) ProtoMessage()

func (*ProjectsReq) ProtoReflect

func (x *ProjectsReq) ProtoReflect() protoreflect.Message

func (*ProjectsReq) Reset

func (x *ProjectsReq) Reset()

func (*ProjectsReq) String

func (x *ProjectsReq) String() string

type Role

type Role int32

Role represents the role of a user.

const (
	// USER represents a regular user.
	Role_USER Role = 0
	// ADMIN represents an admin user.
	Role_ADMIN Role = 1
)

func (Role) Descriptor

func (Role) Descriptor() protoreflect.EnumDescriptor

func (Role) Enum

func (x Role) Enum() *Role

func (Role) EnumDescriptor deprecated

func (Role) EnumDescriptor() ([]byte, []int)

Deprecated: Use Role.Descriptor instead.

func (Role) Number

func (x Role) Number() protoreflect.EnumNumber

func (Role) String

func (x Role) String() string

func (Role) Type

func (Role) Type() protoreflect.EnumType

type Service

type Service struct {
	UnimplementedConsensusServer
	// contains filtered or unexported fields
}

Consensus is the main consensus service.

func New

func New(db *sql.DB) *Service

New creates a new service.

func (*Service) AuthenticateUser

func (s *Service) AuthenticateUser(ctx context.Context, req *AuthReq) (*User, error)

AuthenticateUser authenticates a user and returns the user if valid.

func (*Service) CreateProject

func (s *Service) CreateProject(ctx context.Context, project *Project) (*Project, error)

CreateProject creates a new project.

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, user *User) (*User, error)

CreateUser creates a new user.

func (*Service) GetProjects

func (s *Service) GetProjects(ctx context.Context, req *ProjectsReq) (*Projects, error)

GetProjects returns all the existing projects.

func (*Service) GetUsers

func (s *Service) GetUsers(ctx context.Context, req *GetUsersReq) (*Users, error)

GetUsers returns all the existing users.

type UnimplementedConsensusServer

type UnimplementedConsensusServer struct {
}

UnimplementedConsensusServer must be embedded to have forward compatible implementations.

func (UnimplementedConsensusServer) AuthenticateUser

func (UnimplementedConsensusServer) CreateProject

func (UnimplementedConsensusServer) CreateUser

func (UnimplementedConsensusServer) GetProjects

func (UnimplementedConsensusServer) GetUsers

type UnsafeConsensusServer

type UnsafeConsensusServer interface {
	// contains filtered or unexported methods
}

UnsafeConsensusServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ConsensusServer will result in compilation errors.

type User

type User struct {

	// id is the unique identifier of the user.
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// created_at is the timestamp when the user was created.
	CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// updated_at is the timestamp when the user was last updated.
	UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// first_name is the first name of the user.
	FirstName string `protobuf:"bytes,4,opt,name=first_name,json=firstName,proto3" json:"first_name,omitempty"`
	// last_name is the last name of the user.
	LastName string `protobuf:"bytes,5,opt,name=last_name,json=lastName,proto3" json:"last_name,omitempty"`
	// email is the email address of the user.
	Email string `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"`
	// password is the password of the user.
	Password string `protobuf:"bytes,7,opt,name=password,proto3" json:"password,omitempty"`
	// role is the role of the user.
	Role Role `protobuf:"varint,8,opt,name=role,proto3,enum=service.Role" json:"role,omitempty"`
	// contains filtered or unexported fields
}

User represents a single user.

func DBUserToCoreUser

func DBUserToCoreUser(user client.User) *User

DBUserToCoreUser converts a database user to a core user.

func DBUsersToCoreUsers

func DBUsersToCoreUsers(users ...client.User) []*User

DBUsersToCoreUsers converts a one or more database users to one or more core users.

func (*User) Descriptor deprecated

func (*User) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetCreatedAt

func (x *User) GetCreatedAt() *timestamppb.Timestamp

func (*User) GetEmail

func (x *User) GetEmail() string

func (*User) GetFirstName

func (x *User) GetFirstName() string

func (*User) GetId

func (x *User) GetId() int64

func (*User) GetLastName

func (x *User) GetLastName() string

func (*User) GetPassword

func (x *User) GetPassword() string

func (*User) GetRole

func (x *User) GetRole() Role

func (*User) GetUpdatedAt

func (x *User) GetUpdatedAt() *timestamppb.Timestamp

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

func (x *User) ProtoReflect() protoreflect.Message

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

type Users

type Users struct {

	// users is the list of users.
	Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"`
	// contains filtered or unexported fields
}

UsersResp is the response containing all the existing users.

func (*Users) Descriptor deprecated

func (*Users) Descriptor() ([]byte, []int)

Deprecated: Use Users.ProtoReflect.Descriptor instead.

func (*Users) GetUsers

func (x *Users) GetUsers() []*User

func (*Users) ProtoMessage

func (*Users) ProtoMessage()

func (*Users) ProtoReflect

func (x *Users) ProtoReflect() protoreflect.Message

func (*Users) Reset

func (x *Users) Reset()

func (*Users) String

func (x *Users) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL