co-type

app

import "github.com/sceredi/co-type/broker/cmd/app"

Package main is the entrypoint of the broker application.

Index

config

import "github.com/sceredi/co-type/broker/internal/config"

Package config is responsible for setting up the configuration for the broker application.

Index

func CreateDiscoveryListener

func CreateDiscoveryListener(addr string, lis net.Listener) error

CreateDiscoveryListener creates and starts the gRPC server for the discovery service. It listens on the port specified in the environment variable “BROKER_PORT” and registers the DiscoveryServiceServer with the gRPC server.

domain

import "github.com/sceredi/co-type/broker/internal/domain"

Package domain defines the core domain entities and errors for the broker application.

Index

Variables

var (
    // ErrServerNotFound is returned when a server is not found.
    ErrServerNotFound = errors.New("server not found")
    // ErrServerAlreadyExists is returned when a server already exists.
    ErrServerAlreadyExists = errors.New("server already exists")
    // ErrServerNameInvalid is returned when a server name is invalid.
    ErrServerNameInvalid = errors.New("server name is invalid")
    // ErrServerAddrInvalid is returned when a server address is invalid.
    ErrServerAddrInvalid = errors.New("server address is invalid")
)

type Server

Server represents a server in the broker application.

type Server struct {
    Name string
    Addr string
    Port int32
}

func NewServer

func NewServer(name, addr string, port int32) (*Server, error)

NewServer creates a new Server instance with the given address.

grpc

import "github.com/sceredi/co-type/broker/internal/grpc"

Package grpc implements the gRPC server for the broker service. It provides the necessary handlers and mappers to handle gRPC requests and responses, allowing clients to interact with the broker service using gRPC protocol.

Index

type ControlHandler

ControlHandler implements the ControlServiceServer interface and handles incoming gRPC requests for server management.

type ControlHandler struct {
    control.UnimplementedControlServiceServer
    // contains filtered or unexported fields
}

func NewControlHandler

func NewControlHandler(serverSvc service.ServerService) *ControlHandler

NewControlHandler creates a new instance of ControlHandler with the provided ServerService.

func (*ControlHandler) Manage

func (h *ControlHandler) Manage(stream control.ControlService_ManageServer) error

Manage handles incoming gRPC streams for server management. It listens for messages from the stream and processes them accordingly.

repository

import "github.com/sceredi/co-type/broker/internal/repository"

Package repository defines the interfaces for the repositories used in the application. It provides an abstraction layer for data access, allowing for different implementations without affecting the business logic.

Index

type ServerRepository

ServerRepository defines the interface for managing servers in the broker.

type ServerRepository interface {
    // Create adds a new server to the repository. It returns the created server or an error if the operation fails.
    Create(server *domain.Server) (*domain.Server, error)
}

service

import "github.com/sceredi/co-type/broker/internal/service"

Package service contains the service layer of the broker service. The service layer is responsible for implementing the business logic of the broker service. It defines the interfaces that the handlers will use to interact with the domain models and repositories.

Index

type ServerService

ServerService defines the interface for managing servers in the broker service.

type ServerService interface {
    // Create creates a new server in the broker service. It takes a CreateServerRequest and returns the created Server or an error if the operation fails.
    Create(name, addr string, port int32) (*domain.Server, error)
}

func NewServerService

func NewServerService(serverRepo repository.ServerRepository) ServerService

NewServerService creates a new instance of ServerService with the provided ServerRepository and returns it.

memory

import "github.com/sceredi/co-type/broker/internal/repository/memory"

Package memory provides an in-memory implementation of the repository interfaces defined in the repository package.

Index

func NewServerRepository

func NewServerRepository() repository.ServerRepository

NewServerRepository creates a new instance of ServerRepository.

app

import "github.com/sceredi/co-type/client/cmd/app"

Package main is the entry point of the application.

Index

tui

import "github.com/sceredi/co-type/client/internal/tui"

Package tui defines the TUI model, which is the main component of the TUI. It manages the state of the TUI and the movement between pages.

Index

type Model

Model is the main model of the TUI.

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

func New

func New() Model

New creates a new TUI model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update updates the model based on the given message and returns the updated model and any commands to execute.

func (Model) View

func (m Model) View() tea.View

View returns the view of the model.

pages

import "github.com/sceredi/co-type/client/internal/tui/pages"

Package pages defines some constants of the TUI pages.

Index

Constants

const (
    // Width is the width of the pages.
    Width = 60
    // Height is the height of the pages.
    Height = 30
)

styles

import "github.com/sceredi/co-type/client/internal/tui/styles"

Package styles defines the styles for the TUI components.

Index

Variables

var (
    // ButtonDefault is a style for buttons with padding, border, and bold text.
    ButtonDefault = lipgloss.NewStyle().Padding(0, 3).Border(lipgloss.RoundedBorder()).Bold(true)
    // ButtonPrimary is a style for primary buttons with a green border and foreground.
    ButtonPrimary = ButtonDefault.BorderForeground(Green).Foreground(Green)
    // ButtonDanger is a style for danger buttons with a red border and foreground.
    ButtonDanger = ButtonDefault.BorderForeground(Red).Foreground(Red)
    // ButtonBlue is a style for blue buttons with a blue border and foreground.
    ButtonBlue = ButtonDefault.BorderForeground(Blue).Foreground(Blue)
)

var (
    // Red is a color for errors and warnings.
    Red = lipgloss.Color("124")
    // DarkRed is a darker Red.
    DarkRed = lipgloss.Color("88")
    // Green is a color for success messages and highlights.
    Green = lipgloss.Color("106")
    // DarkGreen is a darker Green.
    DarkGreen = lipgloss.Color("100")
    // Yellow is a color for highlights and accents.
    Yellow = lipgloss.Color("172")
    // Blue is a color for highlights and accents.
    Blue = lipgloss.Color("66")
    // Purple is a color for highlights and accents.
    Purple = lipgloss.Color("132")
    // Acqua is a color for highlights and accents.
    Acqua = lipgloss.Color("72")
    // Gray is a color for secondary text and accents.
    Gray = lipgloss.Color("245")
)

var (
    // PaddingAll is a style with padding of 1 on all sides.
    PaddingAll = lipgloss.NewStyle().Padding(1)
    // PaddingVertical is a style with padding of 1 on the top and bottom.
    PaddingVertical = lipgloss.NewStyle().Padding(1, 0)
    // PaddingHorizontal is a style with padding of 1 on the left and right.
    PaddingHorizontal = lipgloss.NewStyle().Padding(0, 1)
)

Container is a style for a container with padding and a border.

var Container = lipgloss.NewStyle().Padding(1).Border(lipgloss.RoundedBorder(), true)

LabelBold is a style for labels that are bold.

var LabelBold = lipgloss.NewStyle().Bold(true)

func NewContainer

func NewContainer(content string) string

NewContainer returns the given content styled with Container.

func NewLabelBold

func NewLabelBold(content string) string

NewLabelBold returns the given content styled with LabelBold.

common

import "github.com/sceredi/co-type/client/internal/tui/pages/common"

Package common contains reusable components and functions for the TUI pages.

Index

func NewTextinput

func NewTextinput(placeholder string, value string) textinput.Model

NewTextinput creates a new text input with the given placeholder and value.

end

import "github.com/sceredi/co-type/client/internal/tui/pages/end"

Package end defines the end page of the TUI.

Index

type Model

Model is the model for the end page.

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

func New

func New(stats domain.GameStats) Model

New creates a new and page model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the end page model.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update updates the end page model based on the given message.

func (Model) View

func (m Model) View() string

View renders the end page.

game

import "github.com/sceredi/co-type/client/internal/tui/pages/game"

Package game defines the game page of the TUI.

Index

type Model

Model is the model for the game page.

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

func New

func New(game domain.Game) Model

New creates a new game model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the game model.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update updates the game model based on the given message.

func (Model) View

func (m Model) View() string

View renders the game page.

lobby

import "github.com/sceredi/co-type/client/internal/tui/pages/lobby"

Package lobby defines the lobby page of the TUI.

Index

type Model

The Model struct represents the state of the lobby page.

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

func New

func New(player *domain.Player, lobby *domain.Lobby) Model

New creates a new lobby model for the given player and lobby.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model. In this case, it does nothing and returns nil.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update updates the model based on the given message and returns the updated model and any commands to execute.

func (Model) View

func (m Model) View() string

View renders the lobby page as a string.

welcome

import "github.com/sceredi/co-type/client/internal/tui/pages/welcome"

Package welcome defines the welcome page of the TUI.

Index

type Model

Model is the model for the welcome page.

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

func New

func New() Model

New creates a new welcome model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the welcome model.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update updates the welcome model based on the given message.

func (Model) View

func (m Model) View() string

View renders the welcome page.

game_messages

import "github.com/sceredi/co-type/client/internal/tui/pages/game/messages"

Package game_messages defines the messages for the game page.

Index

func NewGameEndCmd

func NewGameEndCmd(stats domain.GameStats) tea.Cmd

NewGameEndCmd returns a command that creates a GameEndMsg.

type GameEndMsg

GameEndMsg is a message that indicates that a game has ended.

type GameEndMsg struct {
    Stats domain.GameStats
}

lobby_messages

import "github.com/sceredi/co-type/client/internal/tui/pages/lobby/messages"

Package lobby_messages defines the messages for the lobby page.

Index

func NewCloseSettingsCmd

func NewCloseSettingsCmd() tea.Cmd

NewCloseSettingsCmd returns a command that creates a CloseSettingsMsg.

func NewLeaveCmd

func NewLeaveCmd() tea.Cmd

NewLeaveCmd returns a command that creates a LeaveMessage.

func NewPlayerReadyCmd

func NewPlayerReadyCmd(name string, isReady bool) tea.Cmd

NewPlayerReadyCmd returns a command that creates a PlayerReadyMsg with the given name and ready status.

func NewStartGameCmd

func NewStartGameCmd(game domain.Game) tea.Cmd

NewStartGameCmd return a command that creates a StartGameMsg.

func NewUpdatePlayerCmd

func NewUpdatePlayerCmd(player *domain.Player, allowedCharacters, blockedCharacters string, backspaceAllowed bool) tea.Cmd

NewUpdatePlayerCmd returns a command that creates an UpdatePlayerMsg with the given player and settings.

type CloseSettingsMsg

CloseSettingsMsg is a message that indicates that the settings modal should be closed.

type CloseSettingsMsg struct{}

type LeaveMsg

LeaveMsg is a message that indicates the player wants to leave the lobby and return to the main menu.

type LeaveMsg struct{}

type PlayerReadyMsg

PlayerReadyMsg is a message that indicates that a player has changed their ready status.

type PlayerReadyMsg struct {
    Name    string
    IsReady bool
}

type StartGameMsg

StartGameMsg is a message that indicates that a game should be started.

type StartGameMsg struct {
    Game domain.Game
}

type UpdatePlayerMsg

UpdatePlayerMsg is a message that indicates that a player’s settings have been updated.

type UpdatePlayerMsg struct {
    Player            *domain.Player
    AllowedCharacters string
    BlockedCharacters string
    BackspaceAllowed  bool
}

welcome_messages

import "github.com/sceredi/co-type/client/internal/tui/pages/welcome/messages"

Package welcome_messages defines the messages for the welcome page of the TUI.

Index

func NewCreateLobbyCmd

func NewCreateLobbyCmd(lobbyCode string, playerName string) tea.Cmd

NewCreateLobbyCmd creates a new command to create a lobby.

func NewJoinLobbyCmd

func NewJoinLobbyCmd(lobbyCode string, playerName string) tea.Cmd

NewJoinLobbyCmd creates a new command to join a lobby with the given ID.

func NewLeaveJoinLobbyCmd

func NewLeaveJoinLobbyCmd() tea.Cmd

NewLeaveJoinLobbyCmd creates a new command to leave the join lobby page and go back to the welcome page.

type JoinLobbyErrorMsg

JoinLobbyErrorMsg is a message that is sent when there is an error joining a lobby.

type JoinLobbyErrorMsg struct {
    Error string
}

type JoinLobbyMsg

JoinLobbyMsg is a message that is sent when the user wants to join a lobby. It contains the ID of the lobby to join.

type JoinLobbyMsg struct {
    Lobby domain.Lobby
}

type LeaveJoinLobbyMsg

LeaveJoinLobbyMsg is a message that is sent when the user wants to leave the join lobby page and go back to the welcome page.

type LeaveJoinLobbyMsg struct{}

header

import "github.com/sceredi/co-type/client/internal/tui/pages/lobby/components/header"

Package header defines the header component of the lobby page.

Index

func Render

func Render(player *domain.Player, lobby *domain.Lobby) string

Render renders the header component for the given player and lobby.

playerinfo

import "github.com/sceredi/co-type/client/internal/tui/pages/lobby/components/playerinfo"

Package playerinfo defines the component that renders the player’s information in the lobby page.

Index

func Render

func Render(player domain.Player) string

Render renders the player information component for the given player.

playerlist

import "github.com/sceredi/co-type/client/internal/tui/pages/lobby/components/playerlist"

Package playerlist defines the player list component of the lobby page.

Index

func Render

func Render(selectedPlayer int, lobby *domain.Lobby) string

Render renders the player list component for the given selected player and lobby.

settings

import "github.com/sceredi/co-type/client/internal/tui/pages/lobby/components/settings"

Package settings provides a bubbletea component to edit player settings

Index

type Model

Model is the bubbletea model for the settings component.

type Model struct {
    PlayerName string
    // contains filtered or unexported fields
}

func New

func New(player *domain.Player) Model

New creates a new settings model for the given player.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model. It starts the blinking cursor for the text inputs.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update updates the model based on the given message.

func (Model) View

func (m Model) View() string

View renders the settings editor.

config

import "github.com/sceredi/co-type/common/config"

Package config contains useful configuration utilities.

Index

func Setup

func Setup()

Setup initializes the configuration.

domain

import "github.com/sceredi/co-type/common/domain"

Package domain contains the domain models for the co-type game.

Index

type Game

Game represents the ongoing game, including the lobby and the current state of the game.

type Game struct {
    Lobby Lobby
    State GameState
}

type GameState

GameState represents the current state of the game.

type GameState struct {
    CorrectChars int
    LastChar     int
    Status       GameStatus
}

type GameStats

GameStats represents the statistics of a game.

type GameStats struct {
    TotalTime time.Duration
    Lobby     Lobby
}

type GameStatus

GameStatus represents the current status of the game.

type GameStatus int

const (
    // Paused indicates that the game is currently paused.
    Paused GameStatus = iota
    // Running indicates that the game is currently running.
    Running
    // Terminated indicates that the game has been terminated.
    Terminated
)

type Lobby

Lobby represents the state of the lobby.

type Lobby struct {
    ID      string
    Players []*Player
    Host    *Player
    Snippet string
}

func NewLobby

func NewLobby(id string, host *Player) Lobby

NewLobby creates a new lobby with the given ID and host player.

func (*Lobby) AddPlayers

func (l *Lobby) AddPlayers(players ...*Player)

AddPlayers adds the given players to the lobby.

type Player

Player represents a player in the lobby.

type Player struct {
    Name              string
    IsReady           bool
    AllowedCharacters string
    BlockedCharacters string
    CanDelete         bool
}

func NewPlayer

func NewPlayer(name string) Player

NewPlayer creates a new player with the given name and default values for other fields.

logger

import "github.com/sceredi/co-type/common/logger"

Package logger contains logging utilities.

Index

func Setup

func Setup()

Setup sets up the default logger for cli services.

control

import "github.com/sceredi/co-type/common/proto/control"

Index

Constants

const (
    ControlService_Manage_FullMethodName = "/control.ControlService/Manage"
)

Variables

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

var ControlService_ServiceDesc = grpc.ServiceDesc{
    ServiceName: "control.ControlService",
    HandlerType: (*ControlServiceServer)(nil),
    Methods:     []grpc.MethodDesc{},
    Streams: []grpc.StreamDesc{
        {
            StreamName:    "Manage",
            Handler:       _ControlService_Manage_Handler,
            ServerStreams: true,
            ClientStreams: true,
        },
    },
    Metadata: "common/proto/control/control.proto",
}

var File_common_proto_control_control_proto protoreflect.FileDescriptor

func RegisterControlServiceServer

func RegisterControlServiceServer(s grpc.ServiceRegistrar, srv ControlServiceServer)

type BrokerEnvelope

Envelopes for communication from the broker to servers.

type BrokerEnvelope struct {

    // Types that are valid to be assigned to Payload:
    //
    //	*BrokerEnvelope_RegisterAck
    //	*BrokerEnvelope_Heartbeat
    Payload isBrokerEnvelope_Payload `protobuf_oneof:"payload"`
    // contains filtered or unexported fields
}

func (*BrokerEnvelope) Descriptor

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

Deprecated: Use BrokerEnvelope.ProtoReflect.Descriptor instead.

func (*BrokerEnvelope) GetHeartbeat

func (x *BrokerEnvelope) GetHeartbeat() *Heartbeat

func (*BrokerEnvelope) GetPayload

func (x *BrokerEnvelope) GetPayload() isBrokerEnvelope_Payload

func (*BrokerEnvelope) GetRegisterAck

func (x *BrokerEnvelope) GetRegisterAck() *RegisterServerAck

func (*BrokerEnvelope) ProtoMessage

func (*BrokerEnvelope) ProtoMessage()

func (*BrokerEnvelope) ProtoReflect

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

func (*BrokerEnvelope) Reset

func (x *BrokerEnvelope) Reset()

func (*BrokerEnvelope) String

func (x *BrokerEnvelope) String() string

type BrokerEnvelope\_Heartbeat

type BrokerEnvelope_Heartbeat struct {
    Heartbeat *Heartbeat `protobuf:"bytes,2,opt,name=heartbeat,proto3,oneof"`
}

type BrokerEnvelope\_RegisterAck

type BrokerEnvelope_RegisterAck struct {
    RegisterAck *RegisterServerAck `protobuf:"bytes,1,opt,name=register_ack,json=registerAck,proto3,oneof"`
}

type ControlServiceClient

ControlServiceClient is the client API for ControlService 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.

The control service definition.

type ControlServiceClient interface {
    // Bidirectional streaming RPC for managing servers.
    Manage(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[ServerEnvelope, BrokerEnvelope], error)
}

func NewControlServiceClient

func NewControlServiceClient(cc grpc.ClientConnInterface) ControlServiceClient

type ControlServiceServer

ControlServiceServer is the server API for ControlService service. All implementations must embed UnimplementedControlServiceServer for forward compatibility.

The control service definition.

type ControlServiceServer interface {
    // Bidirectional streaming RPC for managing servers.
    Manage(grpc.BidiStreamingServer[ServerEnvelope, BrokerEnvelope]) error
    // contains filtered or unexported methods
}

type ControlService\_ManageClient

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type ControlService_ManageClient = grpc.BidiStreamingClient[ServerEnvelope, BrokerEnvelope]

type ControlService\_ManageServer

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type ControlService_ManageServer = grpc.BidiStreamingServer[ServerEnvelope, BrokerEnvelope]

type Heartbeat

Messages for heartbeat to monitor server health.

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

func (*Heartbeat) Descriptor

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

Deprecated: Use Heartbeat.ProtoReflect.Descriptor instead.

func (*Heartbeat) ProtoMessage

func (*Heartbeat) ProtoMessage()

func (*Heartbeat) ProtoReflect

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

func (*Heartbeat) Reset

func (x *Heartbeat) Reset()

func (*Heartbeat) String

func (x *Heartbeat) String() string

type HeartbeatAck

Acknowledgment for heartbeat.

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

func (*HeartbeatAck) Descriptor

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

Deprecated: Use HeartbeatAck.ProtoReflect.Descriptor instead.

func (*HeartbeatAck) ProtoMessage

func (*HeartbeatAck) ProtoMessage()

func (*HeartbeatAck) ProtoReflect

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

func (*HeartbeatAck) Reset

func (x *HeartbeatAck) Reset()

func (*HeartbeatAck) String

func (x *HeartbeatAck) String() string

type RegisterServer

Messages for server registration.

type RegisterServer struct {
    Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
    Host string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"`
    Port int32  `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
    // contains filtered or unexported fields
}

func (*RegisterServer) Descriptor

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

Deprecated: Use RegisterServer.ProtoReflect.Descriptor instead.

func (*RegisterServer) GetHost

func (x *RegisterServer) GetHost() string

func (*RegisterServer) GetName

func (x *RegisterServer) GetName() string

func (*RegisterServer) GetPort

func (x *RegisterServer) GetPort() int32

func (*RegisterServer) ProtoMessage

func (*RegisterServer) ProtoMessage()

func (*RegisterServer) ProtoReflect

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

func (*RegisterServer) Reset

func (x *RegisterServer) Reset()

func (*RegisterServer) String

func (x *RegisterServer) String() string

type RegisterServerAck

Acknowledgment for server registration.

type RegisterServerAck struct {
    Success bool   `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
    Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
    // contains filtered or unexported fields
}

func (*RegisterServerAck) Descriptor

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

Deprecated: Use RegisterServerAck.ProtoReflect.Descriptor instead.

func (*RegisterServerAck) GetMessage

func (x *RegisterServerAck) GetMessage() string

func (*RegisterServerAck) GetSuccess

func (x *RegisterServerAck) GetSuccess() bool

func (*RegisterServerAck) ProtoMessage

func (*RegisterServerAck) ProtoMessage()

func (*RegisterServerAck) ProtoReflect

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

func (*RegisterServerAck) Reset

func (x *RegisterServerAck) Reset()

func (*RegisterServerAck) String

func (x *RegisterServerAck) String() string

type ServerEnvelope

Envelopes for communication between servers and the broker.

type ServerEnvelope struct {

    // Types that are valid to be assigned to Payload:
    //
    //	*ServerEnvelope_Register
    //	*ServerEnvelope_HeartbeatAck
    Payload isServerEnvelope_Payload `protobuf_oneof:"payload"`
    // contains filtered or unexported fields
}

func (*ServerEnvelope) Descriptor

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

Deprecated: Use ServerEnvelope.ProtoReflect.Descriptor instead.

func (*ServerEnvelope) GetHeartbeatAck

func (x *ServerEnvelope) GetHeartbeatAck() *HeartbeatAck

func (*ServerEnvelope) GetPayload

func (x *ServerEnvelope) GetPayload() isServerEnvelope_Payload

func (*ServerEnvelope) GetRegister

func (x *ServerEnvelope) GetRegister() *RegisterServer

func (*ServerEnvelope) ProtoMessage

func (*ServerEnvelope) ProtoMessage()

func (*ServerEnvelope) ProtoReflect

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

func (*ServerEnvelope) Reset

func (x *ServerEnvelope) Reset()

func (*ServerEnvelope) String

func (x *ServerEnvelope) String() string

type ServerEnvelope\_HeartbeatAck

type ServerEnvelope_HeartbeatAck struct {
    HeartbeatAck *HeartbeatAck `protobuf:"bytes,2,opt,name=heartbeat_ack,json=heartbeatAck,proto3,oneof"`
}

type ServerEnvelope\_Register

type ServerEnvelope_Register struct {
    Register *RegisterServer `protobuf:"bytes,1,opt,name=register,proto3,oneof"`
}

type UnimplementedControlServiceServer

UnimplementedControlServiceServer 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 UnimplementedControlServiceServer struct{}

func (UnimplementedControlServiceServer) Manage

func (UnimplementedControlServiceServer) Manage(grpc.BidiStreamingServer[ServerEnvelope, BrokerEnvelope]) error

type UnsafeControlServiceServer

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

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

app

import "github.com/sceredi/co-type/server/cmd/app"

Package main is the entry point of the server application.

Index

config

import "github.com/sceredi/co-type/server/internal/config"

Package config is responsible for setting up the configuration for the server application.

Index

func CreateDiscoveryService

func CreateDiscoveryService(conn *grpc.ClientConn) service.DiscoveryService

CreateDiscoveryService creates a new instance of DiscoveryService using the provided gRPC connection.

grpc

import "github.com/sceredi/co-type/server/internal/grpc"

Package grpc provides the gRPC implementation of the ControlGateway interface for the server service.

Index

type ControlGateway

ControlGateway defines the interface for managing control operations in the server service.

type ControlGateway interface {
    // Register registers the server with the control service using the provided name, host, and port.
    Register(name, host string, port int32) error
}

func NewControlGateway

func NewControlGateway(stream grpc.BidiStreamingClient[control.ServerEnvelope, control.BrokerEnvelope]) ControlGateway

NewControlGateway creates a new instance of ControlGateway with the provided gRPC stream and returns it.

service

import "github.com/sceredi/co-type/server/internal/service"

Package service contains the service layer of the server service. The service layer is responsible for implementing the business logic of the server service. It defines the interfaces that the handlers will use to interact with the domain models and repositories.

Index

type DiscoveryService

DiscoveryService defines the interface for managing service discovery in the server service. It provides a method to register the server with the service discovery mechanism. The Register method is responsible for registering the server and returns an error if the operation fails.

type DiscoveryService interface {
    // Register registers the server with the service discovery mechanism using the provided host and port.
    Register(name, host string, port int32) error
}

func NewDiscoveryService

func NewDiscoveryService(gtw grpc.ControlGateway) DiscoveryService

NewDiscoveryService creates a new instance of DiscoveryService with the provided ControlGateway and returns it.

Generated by gomarkdoc