api

package
v0.0.0-...-9808391 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package api contains the definitions of the habit service's endpoints.

Index

Constants

This section is empty.

Variables

View Source
var File_habit_proto protoreflect.FileDescriptor
View Source
var File_service_proto protoreflect.FileDescriptor
View Source
var Habits_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "habits.Habits",
	HandlerType: (*HabitsServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreateHabit",
			Handler:    _Habits_CreateHabit_Handler,
		},
		{
			MethodName: "ListHabits",
			Handler:    _Habits_ListHabits_Handler,
		},
		{
			MethodName: "TickHabit",
			Handler:    _Habits_TickHabit_Handler,
		},
		{
			MethodName: "GetHabitStatus",
			Handler:    _Habits_GetHabitStatus_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "service.proto",
}

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

Functions

func RegisterHabitsServer

func RegisterHabitsServer(s grpc.ServiceRegistrar, srv HabitsServer)

Types

type CreateHabitRequest

type CreateHabitRequest struct {

	// Name of the new habit. Cannot be empty.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Description of the new habit.
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// Frequency of the new habit. Defaults to once per week.
	WeeklyFrequency *int32 `protobuf:"varint,3,opt,name=weekly_frequency,json=weeklyFrequency,proto3,oneof" json:"weekly_frequency,omitempty"`
	// contains filtered or unexported fields
}

CreateHabitRequest is the message sent to create a habit.

func (*CreateHabitRequest) Descriptor deprecated

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

Deprecated: Use CreateHabitRequest.ProtoReflect.Descriptor instead.

func (*CreateHabitRequest) GetDescription

func (x *CreateHabitRequest) GetDescription() string

func (*CreateHabitRequest) GetName

func (x *CreateHabitRequest) GetName() string

func (*CreateHabitRequest) GetWeeklyFrequency

func (x *CreateHabitRequest) GetWeeklyFrequency() int32

func (*CreateHabitRequest) ProtoMessage

func (*CreateHabitRequest) ProtoMessage()

func (*CreateHabitRequest) ProtoReflect

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

func (*CreateHabitRequest) Reset

func (x *CreateHabitRequest) Reset()

func (*CreateHabitRequest) String

func (x *CreateHabitRequest) String() string

type CreateHabitResponse

type CreateHabitResponse struct {
	Habit *Habit `protobuf:"bytes,1,opt,name=habit,proto3" json:"habit,omitempty"`
	// contains filtered or unexported fields
}

CreateHabitResponse is the response of the create endpoint.

func (*CreateHabitResponse) Descriptor deprecated

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

Deprecated: Use CreateHabitResponse.ProtoReflect.Descriptor instead.

func (*CreateHabitResponse) GetHabit

func (x *CreateHabitResponse) GetHabit() *Habit

func (*CreateHabitResponse) ProtoMessage

func (*CreateHabitResponse) ProtoMessage()

func (*CreateHabitResponse) ProtoReflect

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

func (*CreateHabitResponse) Reset

func (x *CreateHabitResponse) Reset()

func (*CreateHabitResponse) String

func (x *CreateHabitResponse) String() string

type GetHabitStatusRequest

type GetHabitStatusRequest struct {

	// The identifier of the habit we want to retrieve. This field is required.
	HabitId string `protobuf:"bytes,1,opt,name=habit_id,json=habitId,proto3" json:"habit_id,omitempty"`
	// The time for which we want to retrieve the status of a habit.
	// This field is optional, if empty the default value is set to the current time.
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3,oneof" json:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

GetHabitStatusRequest is the request to GetHabitStatus endpoint.

func (*GetHabitStatusRequest) Descriptor deprecated

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

Deprecated: Use GetHabitStatusRequest.ProtoReflect.Descriptor instead.

func (*GetHabitStatusRequest) GetHabitId

func (x *GetHabitStatusRequest) GetHabitId() string

func (*GetHabitStatusRequest) GetTimestamp

func (x *GetHabitStatusRequest) GetTimestamp() *timestamppb.Timestamp

func (*GetHabitStatusRequest) ProtoMessage

func (*GetHabitStatusRequest) ProtoMessage()

func (*GetHabitStatusRequest) ProtoReflect

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

func (*GetHabitStatusRequest) Reset

func (x *GetHabitStatusRequest) Reset()

func (*GetHabitStatusRequest) String

func (x *GetHabitStatusRequest) String() string

type GetHabitStatusResponse

type GetHabitStatusResponse struct {

	// All the information of a habit.
	Habit *Habit `protobuf:"bytes,1,opt,name=habit,proto3" json:"habit,omitempty"`
	// The number of times the habit has been ticked for a given week.
	TicksCount int32 `protobuf:"varint,2,opt,name=ticks_count,json=ticksCount,proto3" json:"ticks_count,omitempty"`
	// contains filtered or unexported fields
}

GetHabitStatusResponse is the response to retrieving the status of a habit.

func (*GetHabitStatusResponse) Descriptor deprecated

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

Deprecated: Use GetHabitStatusResponse.ProtoReflect.Descriptor instead.

func (*GetHabitStatusResponse) GetHabit

func (x *GetHabitStatusResponse) GetHabit() *Habit

func (*GetHabitStatusResponse) GetTicksCount

func (x *GetHabitStatusResponse) GetTicksCount() int32

func (*GetHabitStatusResponse) ProtoMessage

func (*GetHabitStatusResponse) ProtoMessage()

func (*GetHabitStatusResponse) ProtoReflect

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

func (*GetHabitStatusResponse) Reset

func (x *GetHabitStatusResponse) Reset()

func (*GetHabitStatusResponse) String

func (x *GetHabitStatusResponse) String() string

type Habit

type Habit struct {

	// Identifier of the habit
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// Name of the habit.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// Description of the habit.
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	// Frequency, expressed in times per week.
	WeeklyFrequency int32 `protobuf:"varint,4,opt,name=weekly_frequency,json=weeklyFrequency,proto3" json:"weekly_frequency,omitempty"`
	// contains filtered or unexported fields
}

Habit represents an objective one wants to complete a given number of times per week.

func (*Habit) Descriptor deprecated

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

Deprecated: Use Habit.ProtoReflect.Descriptor instead.

func (*Habit) GetDescription

func (x *Habit) GetDescription() string

func (*Habit) GetId

func (x *Habit) GetId() string

func (*Habit) GetName

func (x *Habit) GetName() string

func (*Habit) GetWeeklyFrequency

func (x *Habit) GetWeeklyFrequency() int32

func (*Habit) ProtoMessage

func (*Habit) ProtoMessage()

func (*Habit) ProtoReflect

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

func (*Habit) Reset

func (x *Habit) Reset()

func (*Habit) String

func (x *Habit) String() string

type HabitsClient

type HabitsClient interface {
	// CreateHabit is the endpoint that registers a habit.
	CreateHabit(ctx context.Context, in *CreateHabitRequest, opts ...grpc.CallOption) (*CreateHabitResponse, error)
	// ListHabits is the endpoint that returns all habits.
	ListHabits(ctx context.Context, in *ListHabitsRequest, opts ...grpc.CallOption) (*ListHabitsResponse, error)
	// TickHabit is the endpoint to tick a habit.
	TickHabit(ctx context.Context, in *TickHabitRequest, opts ...grpc.CallOption) (*TickHabitResponse, error)
	// GetHabitStatus is the endpoint to retrieve the status of ticks of a habit.
	GetHabitStatus(ctx context.Context, in *GetHabitStatusRequest, opts ...grpc.CallOption) (*GetHabitStatusResponse, error)
}

HabitsClient is the client API for Habits 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 NewHabitsClient

func NewHabitsClient(cc grpc.ClientConnInterface) HabitsClient

type HabitsServer

type HabitsServer interface {
	// CreateHabit is the endpoint that registers a habit.
	CreateHabit(context.Context, *CreateHabitRequest) (*CreateHabitResponse, error)
	// ListHabits is the endpoint that returns all habits.
	ListHabits(context.Context, *ListHabitsRequest) (*ListHabitsResponse, error)
	// TickHabit is the endpoint to tick a habit.
	TickHabit(context.Context, *TickHabitRequest) (*TickHabitResponse, error)
	// GetHabitStatus is the endpoint to retrieve the status of ticks of a habit.
	GetHabitStatus(context.Context, *GetHabitStatusRequest) (*GetHabitStatusResponse, error)
	// contains filtered or unexported methods
}

HabitsServer is the server API for Habits service. All implementations must embed UnimplementedHabitsServer for forward compatibility

type ListHabitsRequest

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

ListHabitsRequest is the request to list all the habits saved.

func (*ListHabitsRequest) Descriptor deprecated

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

Deprecated: Use ListHabitsRequest.ProtoReflect.Descriptor instead.

func (*ListHabitsRequest) ProtoMessage

func (*ListHabitsRequest) ProtoMessage()

func (*ListHabitsRequest) ProtoReflect

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

func (*ListHabitsRequest) Reset

func (x *ListHabitsRequest) Reset()

func (*ListHabitsRequest) String

func (x *ListHabitsRequest) String() string

type ListHabitsResponse

type ListHabitsResponse struct {

	// habits holds all the stored habits with their specificities (id, name, weekly frequency).
	Habits []*Habit `protobuf:"bytes,1,rep,name=habits,proto3" json:"habits,omitempty"`
	// contains filtered or unexported fields
}

ListHabitsResponse is the response with all the saved habits.

func (*ListHabitsResponse) Descriptor deprecated

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

Deprecated: Use ListHabitsResponse.ProtoReflect.Descriptor instead.

func (*ListHabitsResponse) GetHabits

func (x *ListHabitsResponse) GetHabits() []*Habit

func (*ListHabitsResponse) ProtoMessage

func (*ListHabitsResponse) ProtoMessage()

func (*ListHabitsResponse) ProtoReflect

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

func (*ListHabitsResponse) Reset

func (x *ListHabitsResponse) Reset()

func (*ListHabitsResponse) String

func (x *ListHabitsResponse) String() string

type TickHabitRequest

type TickHabitRequest struct {

	// The identifier of the habit we want to tick. This field is required.
	HabitId string `protobuf:"bytes,1,opt,name=habit_id,json=habitId,proto3" json:"habit_id,omitempty"`
	// The time for which we want to tick a habit.
	// This field is optional, if empty the default value is set to the current time.
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// contains filtered or unexported fields
}

TickHabitRequest holds the identifier of a habit to tick it.

func (*TickHabitRequest) Descriptor deprecated

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

Deprecated: Use TickHabitRequest.ProtoReflect.Descriptor instead.

func (*TickHabitRequest) GetHabitId

func (x *TickHabitRequest) GetHabitId() string

func (*TickHabitRequest) GetTimestamp

func (x *TickHabitRequest) GetTimestamp() *timestamppb.Timestamp

func (*TickHabitRequest) ProtoMessage

func (*TickHabitRequest) ProtoMessage()

func (*TickHabitRequest) ProtoReflect

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

func (*TickHabitRequest) Reset

func (x *TickHabitRequest) Reset()

func (*TickHabitRequest) String

func (x *TickHabitRequest) String() string

type TickHabitResponse

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

TickHabitRequest is the response to TickHabit endpoint. Currently empty but open to grow.

func (*TickHabitResponse) Descriptor deprecated

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

Deprecated: Use TickHabitResponse.ProtoReflect.Descriptor instead.

func (*TickHabitResponse) ProtoMessage

func (*TickHabitResponse) ProtoMessage()

func (*TickHabitResponse) ProtoReflect

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

func (*TickHabitResponse) Reset

func (x *TickHabitResponse) Reset()

func (*TickHabitResponse) String

func (x *TickHabitResponse) String() string

type UnimplementedHabitsServer

type UnimplementedHabitsServer struct {
}

UnimplementedHabitsServer must be embedded to have forward compatible implementations.

func (UnimplementedHabitsServer) CreateHabit

func (UnimplementedHabitsServer) GetHabitStatus

func (UnimplementedHabitsServer) ListHabits

func (UnimplementedHabitsServer) TickHabit

type UnsafeHabitsServer

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

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

Jump to

Keyboard shortcuts

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