itemfilterRPC_serv

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIDExists = errors.New("IDExists")
View Source
var ErrNeedAtLeastOneCandidate = errors.New("NeedAtLeastOneCandidate")
View Source
var ErrNeedAtLeastOneEntitySource = errors.New("NeedAtLeastOneEntitySource")
View Source
var ErrNeedConditions = errors.New("NeedConditions")
View Source
var ErrNeedEntityType = errors.New("NeedEntityType")
View Source
var ErrNeedID = errors.New("NeedID")
View Source
var ErrNeedMetaInfo = errors.New("NeedMetaInfo")
View Source
var ErrNotFound = errors.New("NotFound")
View Source
var ErrNotImplemented = errors.New("NotImplemented")

Functions

This section is empty.

Types

type Server

type Server struct {
	App_Name    string `json:"app_name,omitempty" jsonschema:"required,description=服务名,default=itemfilter"`
	App_Version string `json:"app_version,omitempty" jsonschema:"required,description=服务版本,default=0.0.1"`
	Address     string `json:"address,omitempty" jsonschema:"required,description=服务的主机和端口,default=0.0.0.0:5000"`
	Log_Level   string `` /* 146-byte string literal not displayed */

	// 性能设置
	Max_Recv_Msg_Size                           int  `json:"max_recv_msg_size,omitempty" jsonschema:"description=允许接收的最大消息长度"`
	Max_Send_Msg_Size                           int  `json:"max_send_msg_size,omitempty" jsonschema:"description=允许发送的最大消息长度"`
	Initial_Window_Size                         int  `json:"initial_window_size,omitempty" jsonschema:"description=基于Stream的滑动窗口大小"`
	Initial_Conn_Window_Size                    int  `json:"initial_conn_window_size,omitempty" jsonschema:"description=基于Connection的滑动窗口大小"`
	Max_Concurrent_Streams                      int  `json:"max_concurrent_streams,omitempty" jsonschema:"description=一个连接中最大并发Stream数"`
	Max_Connection_Idle                         int  `json:"max_connection_idle,omitempty" jsonschema:"description=客户端连接的最大空闲时长"`
	Max_Connection_Age                          int  `json:"max_connection_age,omitempty" jsonschema:"description=如果连接存活超过n则发送goaway"`
	Max_Connection_Age_Grace                    int  `json:"max_connection_age_grace,omitempty" jsonschema:"description=强制关闭连接之前允许等待的rpc在n秒内完成"`
	Keepalive_Time                              int  `json:"keepalive_time,omitempty" jsonschema:"description=空闲连接每隔n秒ping一次客户端已确保连接存活"`
	Keepalive_Timeout                           int  `json:"keepalive_timeout,omitempty" jsonschema:"description=ping时长超过n则认为连接已死"`
	Keepalive_Enforcement_Min_Time              int  `json:"keepalive_enforement_min_time,omitempty" jsonschema:"description=如果客户端超过每n秒ping一次则终止连接"`
	Keepalive_Enforcement_Permit_Without_Stream bool `json:"keepalive_enforement_permit_without_stream,omitempty" jsonschema:"description=即使没有活动流也允许ping"`

	//TLS设置
	Server_Cert_Path string `json:"server_cert_path,omitempty" jsonschema:"description=使用TLS时服务端的证书位置"`
	Server_Key_Path  string `json:"server_key_path,omitempty" jsonschema:"description=使用TLS时服务端证书的私钥位置"`
	Ca_Cert_Path     string `json:"ca_cert_path,omitempty" jsonschema:"description=使用TLS时根证书位置"`
	Client_Crl_Path  string `json:"client_crl_path,omitempty" jsonschema:"description=客户端证书黑名单位置"`

	//使用XDS
	XDS                  bool `json:"xds,omitempty" jsonschema:"description=是否使用xDSAPIs"`
	XDS_CREDS            bool `json:"xds_creds,omitempty" jsonschema:"description=是否使用xDSAPIs来接收TLS设置"`
	XDS_Maintenance_Port int  `` /* 133-byte string literal not displayed */

	// 调试,目前admin接口不稳定,因此只使用channelz
	Use_Admin bool `json:"use_admin,omitempty" jsonschema:"description=是否使用grpc-admin方便调试"`

	UnaryInterceptors  []grpc.UnaryServerInterceptor  `json:"-" jsonschema:"nullable"`
	StreamInterceptors []grpc.StreamServerInterceptor `json:"-" jsonschema:"nullable"`

	//使用grpc-gateway
	Use_Gateway              bool   `json:"use_gateway,omitempty" jsonschema:"description=是否使用grpc-gateway提供restful接口"`
	Gateway_Use_TLS          bool   `json:"gateway_use_tls,omitempty" jsonschema:"description=grpc-gateway是否使用TLS以启动https服务"`
	Gateway_Client_Cert_Path string `` /* 150-byte string literal not displayed */
	Gateway_Client_Key_Path  string `` /* 128-byte string literal not displayed */

	//业务配置
	// FilterRedis配置
	FilterRedis_URL         string `` /* 129-byte string literal not displayed */
	FilterRedis_RouteMod    string `` /* 131-byte string literal not displayed */
	FilterRedis_ConnTimeout int    `json:"filterredis_conntimeout" jsonschema:"required,description=过滤器redis请求的最大超时时间单位ms,default=50"`

	// IDgenger
	IDGener string `` /* 159-byte string literal not displayed */

	// 元数据存储
	MetaDataStore_Type        string `` /* 132-byte string literal not displayed */
	MetaDataStore_URL         string `json:"metadatastore_url,omitempty" jsonschema:"description=信息元数据保存服务位置"`
	MetaDataStore_RouteMod    string `` /* 163-byte string literal not displayed */
	MetaDataStore_ConnTimeout int    `` /* 135-byte string literal not displayed */

	// 黑名单
	BlacklistConfig_RangeInfoKey        string `` /* 138-byte string literal not displayed */
	BlacklistConfig_InfoKeySubnamespace string `` /* 169-byte string literal not displayed */
	BlacklistConfig_KeySubnamespace     string `` /* 143-byte string literal not displayed */
	BlacklistConfig_DefaultTTLDays      int    `json:"blacklistconfig_defaultttldays,omitempty" jsonschema:"description=黑名单包括描述信息的默认保存时间"`

	// 范围
	RangeConfig_RangeInfoKey         string  `` /* 126-byte string literal not displayed */
	RangeConfig_InfoKeySubnamespace  string  `` /* 158-byte string literal not displayed */
	RangeConfig_KeySubnamespace      string  `` /* 136-byte string literal not displayed */
	RangeConfig_DefaultTTLDays       int     `json:"rangeconfig_defaultttldays,omitempty" jsonschema:"description=范围包括描述信息的默认保存时间"`
	RangeConfig_FilterType           string  `` /* 139-byte string literal not displayed */
	RangeConfig_DefaultCapacity      int     `json:"rangeconfig_defaultcapacity,omitempty" jsonschema:"description=范围的默认预估容量,default=5000"`
	RangeConfig_DefaultErrorRate     float64 `json:"rangeconfig_defaulterrorrate,omitempty" jsonschema:"description=范围的默认碰撞率"`
	RangeConfig_DefaultExpansion     int     `json:"rangeconfig_defaultexpansion,omitempty" jsonschema:"description=范围的默认扩容倍数,default=1"`
	RangeConfig_DefaultNonScaling    bool    `json:"crangeconfig_defaultnonscaleing,omitempty" jsonschema:"description=范围默认是否会扩容过滤器"`
	RangeConfig_DefaultBucketSize    int     `json:"rangeconfig_defaultbucketsize,omitempty" jsonschema:"description=范围默认CUCKOO桶大小,default=1000"`
	RangeConfig_DefaultMaxIterations int     `json:"rangeconfig_defaultmaxiterations,omitempty" jsonschema:"description=范围默认交换项目的次数,default=4"`

	//namespace
	NamespaceConfig_EntitySourceTypeSubnamespace  string `` /* 133-byte string literal not displayed */
	NamespaceConfig_PickerSubnamespace            string `json:"namespaceconfig_pickersubnamespace,omitempty" jsonschema:"description=Picker的子命名空间名,default=PID"`
	NamespaceConfig_PickerIntervalSubnamespace    string `` /* 131-byte string literal not displayed */
	NamespaceConfig_PickerCounterSubnamespace     string `` /* 129-byte string literal not displayed */
	NamespaceConfig_PickerCounterDateSubnamespace string `json:"namespaceconfig_pickercounterdatesubnamespace,omitempty" jsonschema:"description=PickerCounter键的日期,default=PCD"`

	ContextConfig_KeySubnamespace      string  `` /* 129-byte string literal not displayed */
	ContextConfig_FilterType           string  `` /* 126-byte string literal not displayed */
	ContextConfig_DefaultCapacity      int     `json:"contextconfig_defaultcapacity,omitempty" jsonschema:"description=范围的预估容量,default=5000"`
	ContextConfig_DefaultErrorRate     float64 `json:"contextconfig_defaulterrorrate,omitempty" jsonschema:"description=碰撞率"`
	ContextConfig_DefaultExpansion     int     `json:"contextconfig_defaultexpansion,omitempty" jsonschema:"description=扩容倍数,default=1"`
	ContextConfig_DefaultNonScaling    bool    `json:"contextconfig_defaultnonscaleing,omitempty" jsonschema:"description=不会扩容过滤器"`
	ContextConfig_DefaultBucketSize    int     `json:"contextconfig_defaultbucketsize,omitempty" jsonschema:"description=CUCKOO桶大小,default=1000"`
	ContextConfig_DefaultMaxIterations int     `json:"contextconfig_defaultmaxiterations,omitempty" jsonschema:"description=交换项目的次数,default=4"`
	ContextConfig_DefaultTTLSeconds    int     `json:"contextconfig_defaultttlseconds,omitempty" jsonschema:"description=会话的的默认过期时间,default=900"`

	// Picker
	PickerConfig_TimeRange []string `` /* 161-byte string literal not displayed */
	/// day
	PickerConfig_Day_FilterType           string  `` /* 129-byte string literal not displayed */
	PickerConfig_Day_DefaultCapacity      int     `json:"pickerconfig_day_defaultcapacity,omitempty" jsonschema:"description=范围的预估容量,default=5000"`
	PickerConfig_Day_DefaultErrorRate     float64 `json:"pickerconfig_day_defaulterrorrate,omitempty" jsonschema:"description=碰撞率"`
	PickerConfig_Day_DefaultExpansion     int     `json:"pickerconfig_day_defaultexpansion,omitempty" jsonschema:"description=扩容倍数,default=1"`
	PickerConfig_Day_DefaultNonScaling    bool    `json:"pickerconfig_day_defaultnonscaleing,omitempty" jsonschema:"description=不会扩容过滤器"`
	PickerConfig_Day_DefaultBucketSize    int     `json:"pickerconfig_day_defaultbucketsize,omitempty" jsonschema:"description=CUCKOO桶大小,default=1000"`
	PickerConfig_Day_DefaultMaxIterations int     `json:"pickerconfig_day_defaultmaxiterations,omitempty" jsonschema:"description=交换项目的次数,default=4"`

	/// week
	PickerConfig_Week_FilterType           string  `` /* 130-byte string literal not displayed */
	PickerConfig_Week_DefaultCapacity      int     `json:"pickerconfig_week_defaultcapacity,omitempty" jsonschema:"description=范围的预估容量,default=5000"`
	PickerConfig_Week_DefaultErrorRate     float64 `json:"pickerconfig_week_defaulterrorrate,omitempty" jsonschema:"description=碰撞率"`
	PickerConfig_Week_DefaultExpansion     int     `json:"pickerconfig_week_defaultexpansion,omitempty" jsonschema:"description=扩容倍数,default=1"`
	PickerConfig_Week_DefaultNonScaling    bool    `json:"pickerconfig_week_defaultnonscaleing,omitempty" jsonschema:"description=不会扩容过滤器"`
	PickerConfig_Week_DefaultBucketSize    int     `json:"pickerconfig_week_defaultbucketsize,omitempty" jsonschema:"description=CUCKOO桶大小,default=1000"`
	PickerConfig_Week_DefaultMaxIterations int     `json:"pickerconfig_week_defaultmaxiterations,omitempty" jsonschema:"description=交换项目的次数,default=4"`

	/// month
	PickerConfig_Month_FilterType           string  `` /* 131-byte string literal not displayed */
	PickerConfig_Month_DefaultCapacity      int     `json:"pickerconfig_month_defaultcapacity,omitempty" jsonschema:"description=范围的预估容量,default=5000"`
	PickerConfig_Month_DefaultErrorRate     float64 `json:"pickerconfig_month_defaulterrorrate,omitempty" jsonschema:"description=碰撞率"`
	PickerConfig_Month_DefaultExpansion     int     `json:"pickerconfig_month_defaultexpansion,omitempty" jsonschema:"description=扩容倍数,default=1"`
	PickerConfig_Month_DefaultNonScaling    bool    `json:"pickerconfig_month_defaultnonscaleing,omitempty" jsonschema:"description=不会扩容过滤器"`
	PickerConfig_Month_DefaultBucketSize    int     `json:"pickerconfig_month_defaultbucketsize,omitempty" jsonschema:"description=CUCKOO桶大小,default=1000"`
	PickerConfig_Month_DefaultMaxIterations int     `json:"pickerconfig_month_defaultmaxiterations,omitempty" jsonschema:"description=交换项目的次数,default=4"`

	/// year
	PickerConfig_Year_FilterType           string  `` /* 130-byte string literal not displayed */
	PickerConfig_Year_DefaultCapacity      int     `json:"pickerconfig_year_defaultcapacity,omitempty" jsonschema:"description=范围的预估容量,default=5000"`
	PickerConfig_Year_DefaultErrorRate     float64 `json:"pickerconfig_year_defaulterrorrate,omitempty" jsonschema:"description=碰撞率"`
	PickerConfig_Year_DefaultExpansion     int     `json:"pickerconfig_year_defaultexpansion,omitempty" jsonschema:"description=扩容倍数,default=1"`
	PickerConfig_Year_DefaultNonScaling    bool    `json:"pickerconfig_year_defaultnonscaleing,omitempty" jsonschema:"description=不会扩容过滤器"`
	PickerConfig_Year_DefaultBucketSize    int     `json:"pickerconfig_year_defaultbucketsize,omitempty" jsonschema:"description=CUCKOO桶大小,default=1000"`
	PickerConfig_Year_DefaultMaxIterations int     `json:"pickerconfig_year_defaultmaxiterations,omitempty" jsonschema:"description=交换项目的次数,default=4"`

	/// infi
	PickerConfig_Infi_FilterType           string  `` /* 130-byte string literal not displayed */
	PickerConfig_Infi_DefaultCapacity      int     `json:"pickerconfig_infi_defaultcapacity,omitempty" jsonschema:"description=范围的预估容量,default=5000"`
	PickerConfig_Infi_DefaultErrorRate     float64 `json:"pickerconfig_infi_defaulterrorrate,omitempty" jsonschema:"description=碰撞率"`
	PickerConfig_Infi_DefaultExpansion     int     `json:"pickerconfig_infi_defaultexpansion,omitempty" jsonschema:"description=扩容倍数,default=1"`
	PickerConfig_Infi_DefaultNonScaling    bool    `json:"pickerconfig_infi_defaultnonscaleing,omitempty" jsonschema:"description=不会扩容过滤器"`
	PickerConfig_Infi_DefaultBucketSize    int     `json:"pickerconfig_infi_defaultbucketsize,omitempty" jsonschema:"description=CUCKOO桶大小,default=1000"`
	PickerConfig_Infi_DefaultMaxIterations int     `json:"pickerconfig_infi_defaultmaxiterations,omitempty" jsonschema:"description=交换项目的次数,default=4"`

	// PickerCounter功能设置
	PickerCounterOn                    bool `json:"pickercounter_on,omitempty" jsonschema:"description=是否启用PickerCounter功能"`
	PickerCounterConfig_TTLDays        int  `json:"pickercounterconfig_ttldays,omitempty" jsonschema:"description=PickerCounter保存的天数,default=7"`
	PickerCounterConfig_RangeCounterOn bool `json:"pickercounter_rangecounteron,omitempty" jsonschema:"description=是否启用范围PickerCounter"`
	PickerCounterConfig_RangeTTLDays   int  `json:"pickercounterconfig_rangettldays,omitempty" jsonschema:"description=范围统计PickerCounter保留的天数,default=7"`

	itemfilterRPC_pb.UnimplementedITEMFILTERRPCServer `json:"-"`
	// contains filtered or unexported fields
}

Server grpc的服务器结构体 服务集成了如下特性: 设置收发最大消息长度 健康检测 gzip做消息压缩 接口反射 channelz支持 TLS支持 keep alive 支持

func (*Server) AddRangeSource

AddRangeSource 添加范围内元素

func (*Server) BatchAddRangeSource

BatchAddRangeSource 添加范围内元素

func (*Server) BatchSetEntitySourceUsed

func (s *Server) BatchSetEntitySourceUsed(stream itemfilterRPC_pb.ITEMFILTERRPC_BatchSetEntitySourceUsedServer) error

BatchSetEntitySourceUsed 设置资源在指定条件中已被使用

func (*Server) CheckEntitySource

CheckEntitySource 检查实体资源是否可用

func (*Server) CheckSourceInBlacklist

CheckSourceInBlacklist 检查物品在不在黑名单中

func (*Server) CheckSourceInRange

CheckSourceInRange 检查物品在不在range中

func (*Server) DeleteBlacklist

DeleteBlacklist 删除blackList

func (*Server) DeleteRange

DeleteRange 删除范围

func (*Server) FilterEntitySource

FilterEntitySource 过滤掉不符合的,保留可用的

func (*Server) FilterSourceInBlacklist

FilterSourceInBlacklist 过滤掉在黑名单中的物品,保留不在的部分

func (*Server) FilterSourceNotInRange

FilterSourceNotInRange 过滤掉不在范围内的物品,保留在的部分

func (*Server) GetBlacklistInfo

GetBlacklistInfo 获取黑名单信息

func (*Server) GetBlacklistList

func (s *Server) GetBlacklistList(ctx context.Context, in *emptypb.Empty) (*itemfilterRPC_pb.ListResponse, error)

func (*Server) GetContextStatus

GetContextStatus 获取上下文过滤器状态信息

func (*Server) GetMeta

GetMeta 获取本服务的元信息

func (*Server) GetPickerStatus

GetPickerStatus 获取上下文过滤器状态信息

func (*Server) GetRangeInfo

GetRangeInfo 获取范围信息

func (*Server) GetRangeList

func (s *Server) GetRangeList(ctx context.Context, in *emptypb.Empty) (*itemfilterRPC_pb.ListResponse, error)

GetRangeList 获取范围列表

func (*Server) Main

func (s *Server) Main()

Main 服务的入口函数

func (*Server) MakeGateway

func (s *Server) MakeGateway(grpc_need_client_cert bool) *http.Server

MakeGateway 构造grpc-gateway的http服务

func (*Server) NewBlacklist

NewBlacklist 创建一个新的blacklist

func (*Server) NewContexts

NewContexts 批量创建场景

func (*Server) NewPickers

NewPickers 批量创建Picker

func (*Server) NewRange

NewRange 创建一个新的range,注意创建并不会向其中添加元素,添加元素请调用AddRangeSource接口

func (*Server) PerformanceOpts

func (s *Server) PerformanceOpts()

PerformanceOpts 配置性能调优设置

func (*Server) RegistInterceptor

func (s *Server) RegistInterceptor()

RegistInterceptor 注册拦截器

func (*Server) RegistTools

func (s *Server) RegistTools(serv *grpc.Server) func()

RegistTools 为指定服务注册各种工具

func (*Server) Run

func (s *Server) Run()

Run 执行grpc服务

func (*Server) RunCommonServer

func (s *Server) RunCommonServer()

RunCommonServer 启动常规服务服务

func (*Server) RunXdsServer

func (s *Server) RunXdsServer()

RunXdsServer 启动xds服务服务

func (*Server) SetEntitySourceUsed

func (s *Server) SetEntitySourceUsed(ctx context.Context, in *itemfilterRPC_pb.SetSourceUsedQuery) (*emptypb.Empty, error)

SetEntitySourceUsed 设置资源在指定条件中已被使用

func (*Server) TLSOpts

func (s *Server) TLSOpts()

TLSOpts 配置TLS设置

func (*Server) UpdateBlacklistSource

UpdateBlacklistSource 更新BlackList内不可用资源范围

Jump to

Keyboard shortcuts

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