info

package
v1.0.6-10 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 6 Imported by: 9

Documentation

Index

Constants

View Source
const (
	ContextInfoNameUnknown              = "unknown"
	ContextInfoParameterName            = "name"
	ContextInfoParameterInfoName        = "info.name"
	ContextInfoParameterDescription     = "description"
	ContextInfoParameterInfoDescription = "info.description"
	ContextInfoSectionNameProperties    = "properties"
)

Variables

View Source
var ContainerInfoDescriptor = refer.NewDescriptor("pip-services", "container-info", "default", "*", "1.0")
View Source
var ContainerInfoDescriptor2 = refer.NewDescriptor("pip-services-container", "container-info", "default", "*", "1.0")
View Source
var ContextInfoDescriptor = refer.NewDescriptor("pip-services", "context-info", "default", "*", "1.0")

Functions

func NewDefaultInfoFactory

func NewDefaultInfoFactory() *build.Factory

NewDefaultInfoFactory create a new instance of the factory.

Returns: *build.Factory

Types

type ContextInfo

type ContextInfo struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	ContextId   string            `json:"context_id"`
	StartTime   time.Time         `json:"start_time"`
	Properties  map[string]string `json:"properties"`
}

ContextInfo Context information component that provides detail information about execution context: container or/and process. Most often ContextInfo is used by logging and performance counters to identify source of the collected logs and metrics.

Configuration parameters:
	- name: the context (container or process) name
	- description: human-readable description of the context
	- properties: entire section of additional descriptive properties
	- ...

Example:
	contextInfo := NewContextInfo();
	contextInfo.Configure(context.Background(), NewConfigParamsFromTuples(
		ContextInfoParameterName, "MyMicroservice",
		ContextInfoParameterDescription, "My first microservice"
	));

	context.Name;     	// Result: "MyMicroservice"
	context.ContextId;	// Possible result: "mylaptop"
	context.StartTime;	// Possible result: 2018-01-01:22:12:23.45Z

func NewContextInfo

func NewContextInfo() *ContextInfo

NewContextInfo creates a new instance of this context info.

Returns: *ContextInfo

func NewContextInfoFromConfig

func NewContextInfoFromConfig(ctx context.Context, cfg *config.ConfigParams) *ContextInfo

NewContextInfoFromConfig creates a new instance of this context info.

Parameters:
	- cfg *config.ConfigParams a context configuration parameters.
Returns: *ContextInfo

func (*ContextInfo) Configure

func (c *ContextInfo) Configure(ctx context.Context, cfg *config.ConfigParams)

Configure configures component by passing configuration parameters.

Parameters:
	- config *config.ConfigParams configuration parameters to be set.

func (*ContextInfo) Uptime

func (c *ContextInfo) Uptime() int64

Uptime calculates the context uptime as from the start time.

Returns: int64 number of milliseconds from the context start time.

Jump to

Keyboard shortcuts

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