server

package
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcquireInput

type AcquireInput struct {
	Key  string `path:"key" maxLength:"1024" example:"migration_lock:1" doc:"Key for the lock"`
	Body struct {
		TTL int `json:"ttl" minimum:1 example:60 doc:"Time to live for the lock in seconds"`
	}
}

type AcquireOutput

type AcquireOutput struct {
	Status int
	Body   struct {
		Status string `json:"status" example:"ACQUIRED" doc:"Status of the acquire operation"`
	}
}

type Handler

type Handler struct {
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

func (*Handler) Acquire

func (h *Handler) Acquire(ctx context.Context, input *AcquireInput) (*AcquireOutput, error)

func (*Handler) ConfigureMiddleware

func (h *Handler) ConfigureMiddleware(router *fiber.App)

func (*Handler) Join

func (h *Handler) Join(ctx context.Context, input *JoinInput) (*JoinOutput, error)

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(api huma.API)

func (*Handler) Release

func (h *Handler) Release(ctx context.Context, input *ReleaseInput) (*ReleaseOutput, error)

type JoinInput

type JoinInput struct {
	Body struct {
		ID   string `json:"id" example:"dlock-node-0" doc:"ID of a node"`
		Addr string `json:"addr" example:"localhost:12001" doc:"IP address and a port of a service"`
	}
}

type JoinOutput

type JoinOutput struct {
	Body struct {
		ID   string `json:"id" example:"dlock-node-0" doc:"ID of a node"`
		Addr string `json:"addr" example:"localhost:12001" doc:"IP address and a port of a service"`
	}
}

type ReleaseInput

type ReleaseInput struct {
	Key string `path:"key" maxLength:"1024" example:"migration_lock:1" doc:"Key for the lock"`
}

type ReleaseOutput

type ReleaseOutput struct {
	Status int
	Body   struct {
		Status string `json:"status" example:"RELEASED" doc:"Status of the release operation"`
	}
}

type Service

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

Service provides HTTP service.

func New

func New(logger *logrus.Logger, addr string, store Store) *Service

New returns an uninitialized HTTP service.

func (*Service) Close

func (s *Service) Close()

Close closes the service.

func (*Service) Start

func (s *Service) Start() error

Start starts the service.

type Store

type Store interface {
	// Acquire acquires a lock the given key if it wasn't acquired by somebody else.
	Acquire(key string, ttl int) error

	// Release releases a lock for the given key.
	Release(key string) error

	// Join joins the node, identitifed by nodeID and reachable at addr, to the cluster.
	Join(nodeID string, addr string) error
}

Store is the interface Raft-backed key-value stores must implement.

Jump to

Keyboard shortcuts

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