server

package
v1.127.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobqEndpoint

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

JobqEndpoint implements the DRPCJobQueueServer interface.

func NewEndpoint

func NewEndpoint(log *zap.Logger, queues *QueueMap) *JobqEndpoint

NewEndpoint creates a new endpoint.

func (*JobqEndpoint) Clean

Clean removes all jobs from the queue that were last updated before the requested time. If the given placement is negative, all queues are cleaned.

func (*JobqEndpoint) Delete added in v1.125.2

Delete removes a specific job from the queue by its placement, streamID, and position.

func (*JobqEndpoint) Inspect

Inspect finds a particular job in the queue by its placement, streamID, and position and returns all of the job information.

func (*JobqEndpoint) Len

Len returns the number of jobs in the queues for the requested placement.

func (*JobqEndpoint) Peek

Peek returns the lowest-health job from the queues for the requested placement without removing the job from its queue.

func (*JobqEndpoint) Pop

Pop removes and returns the 'limit' lowest-health jobs from the queues for the requested placements.

func (*JobqEndpoint) Push

Push inserts a job into the appropriate queue for its placement.

func (*JobqEndpoint) PushBatch

PushBatch inserts multiple jobs into the appropriate queues for their placements.

func (*JobqEndpoint) Stat added in v1.125.2

Stat returns statistics about the queues for the requested placement. Note: this is expensive! It requires a full scan of the target queues.

func (*JobqEndpoint) TestingSetAttemptedTime added in v1.125.2

TestingSetAttemptedTime sets the attempted time for a specific job in the queue. This is a testing-only method.

func (*JobqEndpoint) TestingSetUpdatedTime added in v1.126.2

TestingSetUpdatedTime sets the updated time for a specific job in the queue. This is a testing-only method.

func (*JobqEndpoint) Trim

Trim removes all jobs from the queue with health greater than the given value. If the given placement is negative, all queues are trimmed.

func (*JobqEndpoint) Truncate

Truncate removes all jobs from the queue for the requested placement. The queue is not destroyed.

type QueueMap

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

QueueMap is a thread-safe mapping of placement constraints to queues.

func NewQueueMap

func NewQueueMap(log *zap.Logger, queueFactory func(storj.PlacementConstraint) (*jobqueue.Queue, error)) *QueueMap

NewQueueMap creates a new QueueMap.

func (*QueueMap) ChooseQueues added in v1.125.2

func (qm *QueueMap) ChooseQueues(includedPlacements, excludedPlacements []storj.PlacementConstraint) map[storj.PlacementConstraint]*jobqueue.Queue

ChooseQueues returns a map of queues that match the given placement constraints. If includedPlacements is non-empty, only queues for the given placements are returned. If excludedPlacements is non-empty, queues for the given placements are excluded.

func (*QueueMap) GetAllQueues

func (qm *QueueMap) GetAllQueues() map[storj.PlacementConstraint]*jobqueue.Queue

GetAllQueues gets a copy of the current queue map. It is possible for another caller to have destroyed one or more queues between this call and the time when the caller uses the returned map. If this happens, the affected queues will simply appear empty.

func (*QueueMap) GetQueue

func (qm *QueueMap) GetQueue(placement storj.PlacementConstraint) (q *jobqueue.Queue, err error)

GetQueue gets the queue for the given placement. If no queue exists for the given placement, nil is returned.

func (*QueueMap) StopAll

func (qm *QueueMap) StopAll()

StopAll stops and removes all queues.

type Server

type Server struct {
	QueueMap *QueueMap
	// contains filtered or unexported fields
}

Server represents a job queue DRPC server.

func New

func New(log *zap.Logger, listener net.Listener, tlsOpts *tlsopts.Options, retryAfter time.Duration, initAlloc, maxItems, memReleaseThreshold int) (*Server, error)

New creates a new Server instance.

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the address on which the server is listening.

func (*Server) Run

func (s *Server) Run(ctx context.Context) (err error)

Run runs the server (accepting connections on the listener) until the context is canceled.

func (*Server) SetTimeFunc

func (s *Server) SetTimeFunc(timeFunc func() time.Time)

SetTimeFunc sets the time function for all queues currently initialized in the server. This is primarily used for testing to control the timestamps used in the queue.

Importantly, this will not affect queues to be initialized after this point.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳