lccc_core

package
v0.0.0-...-631233f Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const KEY_C_DATA_SANDBOX = "data_sandbox" // 服务专有的数据沙箱
View Source
const KEY_C_SERVICE_BASE_INFO = "service_base_info" // 服务基础信息
View Source
const KEY_C_SERVICE_INSTANCE = "service_instance" // 服务实例
View Source
const KEY_C_SYSTEM_SETTINGS_DEFINE = "system_settings_define" // 服务系统设置定义
View Source
const KEY_C_SYSTEM_SETTINGS_VALUE = "system_settings_value" // 服务系统设置实际值存储

Variables

This section is empty.

Functions

func GetDefaultRegistryContext

func GetDefaultRegistryContext() context.Context

Types

type CoreServiceStruct

type CoreServiceStruct struct {
	InstanceKey string `json:"instance_key"` // 服务实例的唯一键,系统运行时随机生成
	// 服务注册相关
	CoreStartParams *CoreStartParams                `json:"core_start_params"`     // 核心启动时传入的参数
	ServiceInstance *lccc_model.ServiceInstanceInfo `json:"self_service_instance"` // 服务自身的运行实例信息,根据配置和各种运行时信息,内部生成
	// 运行时缓存
	AllServiceInstancePoolCache map[string]map[string]*lccc_model.ServiceInstanceInfo `json:"all_service_instance_pool_cache"` // 所有服务实例信息池缓存,监听到服务实例有变动时刷新
	AllServiceBaseInfoPoolCache map[string]*lccc_model.ServiceBaseInfo
}

系统服务

func CoreService

func CoreService() *CoreServiceStruct

单例函数

func (*CoreServiceStruct) FastGetAllServiceBaseInfo

func (cs *CoreServiceStruct) FastGetAllServiceBaseInfo() map[string]*lccc_model.ServiceBaseInfo

快速获取所有服务的基础信息池(从缓存中获取)

func (*CoreServiceStruct) FastGetAllServiceInstance

func (cs *CoreServiceStruct) FastGetAllServiceInstance() map[string]map[string]*lccc_model.ServiceInstanceInfo

快速获取所有服务的实例池(从缓存中获取)

func (*CoreServiceStruct) GenerateMicroRegistry

func (cs *CoreServiceStruct) GenerateMicroRegistry(config *lccc_model.GeneralConfig) registry.Registry

func (*CoreServiceStruct) GetAllServiceBaseInfo

func (cs *CoreServiceStruct) GetAllServiceBaseInfo() (map[string]*lccc_model.ServiceBaseInfo, error)

从注册中心中获取所有服务的基本信息,无视缓存,直接从注册中心中获取最中心的数据

func (*CoreServiceStruct) GetAllServiceInstance

func (cs *CoreServiceStruct) GetAllServiceInstance() (map[string]map[string]*lccc_model.ServiceInstanceInfo, error)

获取注册中心中所有服务实例,无视缓存,直接从注册中心中重新获取最新数据

func (*CoreServiceStruct) RegisterInstance

func (cs *CoreServiceStruct) RegisterInstance() error

[instance]将自己的服务实例注册到注册中心服务实例列表中

func (*CoreServiceStruct) RegisterServiceBaseInfo

func (cs *CoreServiceStruct) RegisterServiceBaseInfo() error

func (*CoreServiceStruct) RegisterSystemSettingsDefine

func (cs *CoreServiceStruct) RegisterSystemSettingsDefine() error

[system_settings_define]向注册中心中写入本系统的系统设置定义数据

func (*CoreServiceStruct) Start

func (cs *CoreServiceStruct) Start(params *CoreStartParams) error

供各种服务调用,启动时候调用此函数来在注册中心注册服务实例

func (*CoreServiceStruct) StartWatchingAllService

func (cs *CoreServiceStruct) StartWatchingAllService()

开始观察所有注册中心中的服务的变动,如果有变动,及时刷新

type CoreStartParams

type CoreStartParams struct {
	RunGrpcService                 bool                               `json:"run_grpc_service"`         // 是否启用grpc服务,如网关调用时传false即可
	ServiceGeneralConfig           *lccc_model.GeneralConfig          `json:"service_general_config"`   // 通用配置,通常服务从本地配置文件中读取
	ServiceBaseInfo                *lccc_model.ServiceBaseInfo        `json:"service_base_info"`        // 服务的基础信息
	ServiceApplicationInfo         *lccc_model.ServiceApplicationInfo `json:"service_application_info"` // 服务可执行程序的应用信息,如版本数据等
	GrpcServiceImplRegisterHandler func(server server.Server)         // Grpc服务impl注册函数
	SystemSettingsDefine           *lccc_model.SystemSettingsDefine   `json:"system_settings_define"` // 服务所需系统设置定义
}

注册微服务的时候需要传进来的配置信息

type DataSandboxServiceStruct

type DataSandboxServiceStruct struct {
	DataSandboxContext config.Config
}

func DataSandboxService

func DataSandboxService() *DataSandboxServiceStruct

单例函数

func (*DataSandboxServiceStruct) Get

func (dss *DataSandboxServiceStruct) Get(dataKey string) string

func (*DataSandboxServiceStruct) Init

func (dss *DataSandboxServiceStruct) Init() error

func (*DataSandboxServiceStruct) Set

func (dss *DataSandboxServiceStruct) Set(dataKey, newValue string)

func (*DataSandboxServiceStruct) Watch

func (dss *DataSandboxServiceStruct) Watch(dataKey string, callback func(string))

type SystemSettingsServiceStruct

type SystemSettingsServiceStruct struct {
	SystemSettingsContext         config.Config
	SystemSettingsGroupDefinePool map[string]*lccc_model.SystemSettingGroupDefine
	SystemSettingsItemDefinePool  map[string]map[string]*lccc_model.SystemSettingItemDefine
}

func SystemSettingsService

func SystemSettingsService() *SystemSettingsServiceStruct

单例函数

func (*SystemSettingsServiceStruct) AutoFixSystemSettingsValue

func (sss *SystemSettingsServiceStruct) AutoFixSystemSettingsValue() error

func (*SystemSettingsServiceStruct) Get

func (sss *SystemSettingsServiceStruct) Get(settingsGroupKey, settingItemKey string) string

func (*SystemSettingsServiceStruct) GetSystemSettingItemDefaultValue

func (sss *SystemSettingsServiceStruct) GetSystemSettingItemDefaultValue(settingsGroupKey, settingItemKey string) string

获取系统设置子项定义的默认值,如果事先没定义过这个系统设置项,那么将返回空字符串

func (*SystemSettingsServiceStruct) GetSystemSettingItemDefine

func (sss *SystemSettingsServiceStruct) GetSystemSettingItemDefine(settingsGroupKey, settingItemKey string) *lccc_model.SystemSettingItemDefine

获取系统设置子项定义实例,如果事先没定义过这个系统设置项,那么将返回nil

func (*SystemSettingsServiceStruct) GetSystemSettingsGroupDefine

func (sss *SystemSettingsServiceStruct) GetSystemSettingsGroupDefine(settingsGroupKey string) *lccc_model.SystemSettingGroupDefine

获取系统设置定义实例,如果事先没定义过这个分组,那么将返回nil

func (*SystemSettingsServiceStruct) Init

func (sss *SystemSettingsServiceStruct) Init() error

func (*SystemSettingsServiceStruct) KGet

func (*SystemSettingsServiceStruct) KSet

func (*SystemSettingsServiceStruct) KWatch

func (*SystemSettingsServiceStruct) Set

func (sss *SystemSettingsServiceStruct) Set(settingsGroupKey, settingItemKey, newValue string)

func (*SystemSettingsServiceStruct) Watch

func (sss *SystemSettingsServiceStruct) Watch(settingsGroupKey, settingItemKey string, callback func(string))

Jump to

Keyboard shortcuts

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