signals

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: Apache-2.0 Imports: 7 Imported by: 1

README

component-signals - Settings component for shutdown signaling

GoDoc

Bugs Code Smells Coverage Lines of Code Maintainability Rating Quality Gate Status Reliability Rating Security Rating Technical Debt Vulnerabilities

autoauto- [component-signals - Settings component for shutdown signaling](#component-signals---settings-component-for-shutdown-signaling)auto - [Overview](#overview)auto - [Quick Start](#quick-start)auto - [Status](#status)auto - [Contributing](#contributing)auto - [Building And Testing](#building-and-testing)auto - [License](#license)auto - [Contributing Agreement](#contributing-agreement)autoauto

Overview

This is a settings that enables constructing a metrics gathering component that orchestrates fanning in various shutdown signals for a system. It currently support OS signals but can be extended to support other forms.

Quick Start

package main

import (
    "context"
    "net/http"

    signals "github.com/asecurityteam/component-signals"
    "github.com/asecurityteam/settings/v2"
)

func main() {
    ctx := context.Background()
    envSource := settings.NewEnvSource(os.Environ())

    sig, _ := signals.New(ctx, envSource)

    <-sig
    fmt.Println("shut down")
}

Status

This project is in incubation which means we are not yet operating this tool in production and the interfaces are subject to change.

Contributing

Building And Testing

We publish a docker image called SDCLI that bundles all of our build dependencies. It is used by the included Makefile to help make building and testing a bit easier. The following actions are available through the Makefile:

  • make dep

    Install the project dependencies into a vendor directory

  • make lint

    Run our static analysis suite

  • make test

    Run unit tests and generate a coverage artifact

  • make integration

    Run integration tests and generate a coverage artifact

  • make coverage

    Report the combined coverage for unit and integration tests

License

This project is licensed under Apache 2.0. See LICENSE.txt for details.

Contributing Agreement

Atlassian requires signing a contributor's agreement before we can accept a patch. If you are an individual you can fill out the individual CLA. If you are contributing on behalf of your company then please fill out the corporate CLA.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	OS *OSComponent
}

Component enables creation of signal handlers to shut down a system.

func NewComponent

func NewComponent() *Component

NewComponent populates any defaults.

func (*Component) New

func (c *Component) New(ctx context.Context, conf *Config) (Signal, error)

New generates a new Signal from all installed signals.

func (*Component) Settings

func (c *Component) Settings() *Config

Settings generates a default configuration.

type Config

type Config struct {
	Installed []string `description:"Which signal handlers are installed. Choices are OS."`
	OS        *OSConfig
}

Config contains all configuration for enabling various shut down signals.

func (*Config) Description

func (*Config) Description() string

Description of the configuration for help output.

func (*Config) Name

func (*Config) Name() string

Name of the configuration as it appears in a file.

type OSComponent

type OSComponent struct{}

OSComponent enables creation of an OS signal handler.

func (*OSComponent) New

func (*OSComponent) New(_ context.Context, conf *OSConfig) (Signal, error)

New generates a new Signal using OS signals.

func (*OSComponent) Settings

func (*OSComponent) Settings() *OSConfig

Settings generates a default configuration.

type OSConfig

type OSConfig struct {
	Signals []int `description:"Which signals to listen for."`
}

OSConfig contains configuration for creating an OSSignal listener.

func (*OSConfig) Description

func (*OSConfig) Description() string

Description of the configuration for help output.

func (*OSConfig) Name

func (*OSConfig) Name() string

Name of the configuration as it might appear in a file.

type Signal

type Signal chan error

Signal indicates that a system should shut down.

func Load

func Load(ctx context.Context, source settings.Source, c *Component) (Signal, error)

Load is a convenience method for binding the source to the component.

func New

func New(ctx context.Context, source settings.Source) (Signal, error)

New is the top-level entry point for creating a new shutdown signal.

Jump to

Keyboard shortcuts

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