castor

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright 2022 Huawei Cloud Computing Technologies Co., Ltd.

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.

Copyright 2022 Huawei Cloud Computing Technologies Co., Ltd.

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.

Copyright 2022 Huawei Cloud Computing Technologies Co., Ltd.

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.

Copyright 2022 Huawei Cloud Computing Technologies Co., Ltd.

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.

Copyright 2022 Huawei Cloud Computing Technologies Co., Ltd.

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.

Index

Constants

View Source
const (
	DataId          internalTagKey = "_dataID"
	Algorithm       internalTagKey = "_algo"
	ConfigFile      internalTagKey = "_cfg"
	ProcessType     internalTagKey = "_processType"
	MessageType     internalTagKey = "_msgType"
	ErrInfo         internalTagKey = "_errInfo"
	TaskID          internalTagKey = "_taskID"
	AnomalyNum      internalTagKey = "_anomalyNum"
	QueryMode       internalTagKey = "_queryMode"
	ConnID          internalTagKey = "_connID"
	FieldKeys       internalTagKey = "field_keys"
	PostProcessType internalTagKey = "type"
	ResultSeries    internalTagKey = "series"
	OutputInfo      internalTagKey = "_outputInfo"
)
View Source
const (
	AnomalyLevel resultFieldKey = "anomalyLevel"
	DataTime     resultFieldKey = "time"
)
View Source
const (
	NormalQuery     queryMode = "0"
	ContinuousQuery queryMode = "1"
)
View Source
const (
	DATA messageType = "data"
)

Variables

View Source
var DesiredFieldKeySet = map[string]struct{}{
	string(AnomalyLevel): {},
}

Functions

func BuildNumericRecord

func BuildNumericRecord() array.Record

mock castor response

func GetMetaValueFromRecord

func GetMetaValueFromRecord(data array.Record, key string) (string, *errno.Error)

return value from record's metadata according to key

func IsInternalKey

func IsInternalKey(key string) bool

check if key is internal

func MockPyWorker

func MockPyWorker(addr string) error

mock pyworker to handle data

func NewRespChan

func NewRespChan(size int) (*respChan, *errno.Error)

return response channel with buffer size

Types

type ByteReadReader

type ByteReadReader interface {
	io.Reader
	io.ByteReader
}

type Service

type Service struct {
	services.Base

	Config config.Castor
	// contains filtered or unexported fields
}

func GetService

func GetService() *Service

GetService return service instance

func MockCastorService

func MockCastorService(port int) (*Service, *observer.ObservedLogs, error)

use default configuration and replace logger with observable one for test

func NewService

func NewService(c config.Castor) *Service

NewService return an new service instance

func (*Service) Close

func (s *Service) Close() error

Close release internal client and close channel, service will mark as not alive, any castor query will not be processed

func (*Service) DeregisterResultChan

func (s *Service) DeregisterResultChan(id string)

DeregisterResultChan deregister an channel with id, response from computation node will be dropped if correspond id not found

func (*Service) HandleData

func (s *Service) HandleData(record array.Record)

HandleData will send data to computation node through internal client

func (*Service) IsAlive

func (s *Service) IsAlive() bool

IsAlive return service running status

func (*Service) Open

func (s *Service) Open() error

Open start service

func (*Service) RegisterResultChan

func (s *Service) RegisterResultChan(id string, ch *respChan)

RegisterResultChan register an channel with id, response from computation node will be dispatched according to id

func (*Service) ResultChan

func (s *Service) ResultChan() chan<- array.Record

ResultChan store result from computation node

Jump to

Keyboard shortcuts

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