Home / File/ services.go — fiber Source File

services.go — fiber Source File

Architecture documentation for services.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberCore Context 1 imports 1 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  1e8c99f4_bd0c_bc1c_6ed5_b509aac16b78["services.go"]
  cc7104af_aece_1fe5_3985_791c7f34910c["context"]
  1e8c99f4_bd0c_bc1c_6ed5_b509aac16b78 --> cc7104af_aece_1fe5_3985_791c7f34910c
  style 1e8c99f4_bd0c_bc1c_6ed5_b509aac16b78 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

package fiber

import (
	"context"
	"errors"
	"fmt"
	"io"

	"github.com/gofiber/utils/v2"
)

// Service is an interface that defines the methods for a service.
type Service interface {
	// Start starts the service, returning an error if it fails.
	Start(ctx context.Context) error

	// String returns a string representation of the service.
	// It is used to print a human-readable name of the service in the startup message.
	String() string

	// State returns the current state of the service.
	State(ctx context.Context) (string, error)

	// Terminate terminates the service, returning an error if it fails.
	Terminate(ctx context.Context) error
}

// hasConfiguredServices Checks if there are any services for the current application.
func (app *App) hasConfiguredServices() bool {
	return len(app.configured.Services) > 0
}

func (app *App) validateConfiguredServices() error {
	return validateServicesSlice(app.configured.Services)
}

func validateServicesSlice(services []Service) error {
	for idx, srv := range services {
		if srv == nil {
			return fmt.Errorf("fiber: service at index %d is nil", idx)
		}
	}
	return nil
}

// initServices If the app is configured to use services, this function registers
// a post shutdown hook to shutdown them after the server is closed.
// This function panics if there is an error starting the services.
func (app *App) initServices() {
	if !app.hasConfiguredServices() {
		return
	}

	if err := app.startServices(app.servicesStartupCtx()); err != nil {
		panic(err)
	}
}

// servicesStartupCtx Returns the context for the services startup.
// If the ServicesStartupContextProvider is not set, it returns a new background context.
// ... (118 more lines)

Domain

Subdomains

Types

Dependencies

  • context

Frequently Asked Questions

What does services.go do?
services.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Context subdomain.
What functions are defined in services.go?
services.go defines 1 function(s): validateServicesSlice.
What does services.go depend on?
services.go imports 1 module(s): context.
Where is services.go in the architecture?
services.go is located at services.go (domain: FiberCore, subdomain: Context).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free