callout

package
v0.0.0-...-fb315dc Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 24 Imported by: 6

README

HAL Callout Service

The service allows for callout to be invoked via 4 different methods.

  1. Telegram Message
  2. JIRA Task
  3. SNMP Track
  4. Phone Call via Amazon AWS Connect

Server

Service

If you wish to include the callout service within your code, you would need to create a new instance of the service.

	calloutService := callout.NewService(alertService, snmpService, jiraService, aws)

snmp, jira and aws can be set to nil if you do not wish to use them.

REST Server

A rest server is available, to configure

mux := http.NewServeMux()
mux.Handle("/callout/", callout.MakeHandler(calloutService, httpLogger, machineLearningService))

machine learning service can be set to nil if you do not wish to record the requests.

Invoke Callout

Rest endpoint is available at http://<hal server>:8000/callout/. Send a POST request with JSON Format

{
    "Title" : "some title",
    "Message": "some message"
}

##Client A remote HTTP proxy client is provided for easy access to the callout.

Examples are located withint he proxy_test.go file

Standard HTTP
func ExampleNewCalloutProxy() {
	os.Setenv("HAL_ENDPOINT","http://<some server>:8000")
	svc := NewCalloutProxy()
	svc.InvokeCallout(context.TODO(),"Test Message","The body of the message goes in here")
}
Kubernetes
func ExampleNewKubernetesCalloutProxy() {
	svc := NewKubernetesCalloutProxy("")
	svc.InvokeCallout(context.TODO(),"Test Message","The body of the message goes in here")
}

Documentation

Overview

Package callout provides a mechanism to invoke various different forms of callout depending on the services linked when creating the service.

Package callout is a generated GoMock package.

Package callout is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHandler

func MakeHandler(service Service, logger kitlog.Logger, ml machineLearning.Service) http.Handler

func NewAckCommand

func NewAckCommand(alert alert.Service, telegram telegram.Store, store Store) telegram.Command

Types

type MockService

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

MockService is a mock of Service interface

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockService) InvokeCallout

func (m *MockService) InvokeCallout(ctx context.Context, chat uint32, title, message string, ack bool) error

InvokeCallout mocks base method

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService

func (*MockServiceMockRecorder) InvokeCallout

func (mr *MockServiceMockRecorder) InvokeCallout(ctx, chat, title, message, ack interface{}) *gomock.Call

InvokeCallout indicates an expected call of InvokeCallout

type MockStore

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

MockStore is a mock of Store interface

func NewMockStore

func NewMockStore(ctrl *gomock.Controller) *MockStore

NewMockStore creates a new mock instance

func (*MockStore) AddAck

func (m *MockStore) AddAck(fields map[string]string, chat uint32, phone, name string) error

AddAck mocks base method

func (*MockStore) Bump

func (m *MockStore) Bump(chat uint32) error

Bump mocks base method

func (*MockStore) DeleteAck

func (m *MockStore) DeleteAck(chat uint32) error

DeleteAck mocks base method

func (*MockStore) EXPECT

func (m *MockStore) EXPECT() *MockStoreMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

type MockStoreMockRecorder

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

MockStoreMockRecorder is the mock recorder for MockStore

func (*MockStoreMockRecorder) AddAck

func (mr *MockStoreMockRecorder) AddAck(fields, chat, phone, name interface{}) *gomock.Call

AddAck indicates an expected call of AddAck

func (*MockStoreMockRecorder) Bump

func (mr *MockStoreMockRecorder) Bump(chat interface{}) *gomock.Call

Bump indicates an expected call of Bump

func (*MockStoreMockRecorder) DeleteAck

func (mr *MockStoreMockRecorder) DeleteAck(chat interface{}) *gomock.Call

DeleteAck indicates an expected call of DeleteAck

type SendCalloutRequest

type SendCalloutRequest struct {
	// Title for the JIRA ticket
	//
	// required: true
	Title string `json:"title"`

	// Message that will be used for the Telegram Alert, the Jira Ticket and the Alexa Callout
	//
	// required: true
	Message string `json:"message"`

	// RequireAcknowledge when set to true, will require the user to /ack the call on telegram.
	RequireAcknowledge bool `json:"require_acknowledge"`
}

Callout Request

swagger:model

type Service

type Service interface {
	//InvokeCallout will invoke snmp if configured, then create a jira ticket if configured.
	InvokeCallout(ctx context.Context, chat uint32, title, message string, ack bool) error
}

Service interface for the Callout Service

func NewInstrumentService

func NewInstrumentService(counter metrics.Counter, errorCount metrics.Counter, latency metrics.Histogram,
	s Service) Service

func NewLoggingService

func NewLoggingService(logger log.Logger, s Service) Service

func NewService

func NewService(alert alert.Service, firstcall firstCall.Service, snmp snmp.Service, jira jira.Service, alexa halaws.Service, store Store) Service

NewService creates a new Callout Service. Parameters can be passed in as Nil should they not be required. any items that are nil will simply not be invoked.

type Store

type Store interface {
	AddAck(fields map[string]string, chat uint32, phone string, name string) error

	DeleteAck(chat uint32) error
	Bump(chat uint32) error
	// contains filtered or unexported methods
}

func NewStore

func NewStore(database *mgo.Database) Store

Jump to

Keyboard shortcuts

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