pkg

package
v0.0.0-...-58f2448 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

* Copyright 2017-2018 IBM Corporation * * 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 2017-2018 IBM Corporation * * 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 2017-2018 IBM Corporation * * 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 2017-2018 IBM Corporation * * 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

This section is empty.

Variables

View Source
var JobQueue chan JobRequest

JobQueue will hold all incoming data as a queue

View Source
var WorkerPool chan chan JobRequest

Functions

func HandleInstances

func HandleInstances(insts []*metric.InstanceMsg)

HandleInstances extracts telemetry data from incoming request from mixer and put it into the global queue

func SendHttpRequest

func SendHttpRequest(method string, key string, link string, body io.Reader) (string, error)

SendHttpRequest initialize an HTTP client and call NewRelic REST API

func StartDispatcher

func StartDispatcher(maxWorkers int)

Types

type JobRequest

type JobRequest struct {
	PayLoad []*metric.InstanceMsg
}

JobRequest presents the struct of payload that contains telemetry data come from mixer and insert Insight Event through NewRelic REST API

type NewRelicGrpcAdapter

type NewRelicGrpcAdapter struct {
	// contains filtered or unexported fields
}

NewRelicGrpcAdapter supports metric template.

func (*NewRelicGrpcAdapter) Addr

func (s *NewRelicGrpcAdapter) Addr() string

Addr returns the listening address of the server

func (*NewRelicGrpcAdapter) Close

func (s *NewRelicGrpcAdapter) Close() error

Close gracefully shuts down the server; used for testing

func (*NewRelicGrpcAdapter) HandleMetric

HandleMetric records metric entries

func (*NewRelicGrpcAdapter) Run

func (s *NewRelicGrpcAdapter) Run(shutdown chan error)

Run starts the server run

type Server

type Server interface {
	Addr() string
	Close() error
	Run(shutdown chan error)
}

Server is basic server interface

func NewGrpcAdapter

func NewGrpcAdapter(addr string) (Server, error)

NewGrpcAdapter creates a new gRPC adapter that listens at provided port.

type Worker

type Worker struct {
	ID         int
	Job        chan JobRequest
	WorkerPool chan chan JobRequest
	QuitChan   chan bool
}

Worker represents the object which would retrieve Job, extract payload

func NewWorker

func NewWorker(id int, jobQueue chan chan JobRequest) Worker

NewWorker creates a new Worker and regist it into the available worker pool

func (*Worker) Start

func (w *Worker) Start()

Start will start the worker and goto an infinite loop to receive job and handle it

func (*Worker) Stop

func (w *Worker) Stop()

Stop tells the worker to stop listening and handle the request

Jump to

Keyboard shortcuts

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