components

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

README

components

Components repo is used to load components for a web app. Such as MySQL, Redis, MQ etc.

In ./components, there are a file:

  • components.go: It defined the Component struct used to load different components. The Component has some methods:
    • Load
    • Start
    • GetConfig

In the child directories, it's the implementation of the components. For example, in ./components/redisx, it's the implementation of Redis.

In each different implementation, it should have a global map used to store all source of this component. For example, we can use 3 Redis service and named with 'default', 'lock', 'others'. We can get the specified variable/pointer by the source name.

Surely, there must Init and GetXXX methods for each component to get init or get an instance. The Init method will be used to start the web app automatically. So it should receive a fixed parameter.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component[T any] struct {
	// contains filtered or unexported fields
}

func Load

func Load[T any](configValue map[string]config.Value, initMethod func(cfg ConfigMap[*T]) (func() error, error)) (t *T, components *Component[*T])

func (*Component[T]) GetConfig

func (s *Component[T]) GetConfig() ConfigMap[T]

func (*Component[T]) Start

func (s *Component[T]) Start() error

type ConfigMap

type ConfigMap[T any] map[string]T

Directories

Path Synopsis
consumer command
producer command

Jump to

Keyboard shortcuts

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