go_runnable

package module
v0.0.0-...-23af8d1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

README

go-runnable

A simple and easy way for command-line applications to execute tasks and handle signals.

License

Copyright 2024 Mohammad Hadi Hosseinpour

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.```

Documentation

Index

Constants

View Source
const (
	ContextValueKeyWaitGroup = ContextValuesOffset + iota
	ContextValueKeyLogger
	ContextValueKeyConfig
)
View Source
const ContextValuesOffset = 0xFF0

Variables

View Source
var ErrAlreadyRunning = ErrStillRunning
View Source
var ErrRunFuncNil = errors.New("run func is nil")
View Source
var ErrStillRunning = errors.New("runnable running")

Functions

func ContextConfig

func ContextConfig(c context.Context) any

func ContextLogger

func ContextLogger(c context.Context) logging.Logger

func ContextWaitGroup

func ContextWaitGroup(c context.Context) *sync.WaitGroup

func ContextWithValues

func ContextWithValues(parent context.Context, offset int, values ...any) context.Context

ContextWithValues creates a context with given values stored as an array of sequentially indexed values. Values may be accessed with the seq index. An offset can be used to prevent accidental overrides.

func Run

func Run(r Runnable, config any, logger logging.Logger, ctx context.Context) error

Types

type Runnable

type Runnable func(ctx context.Context) error

Jump to

Keyboard shortcuts

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