Documentation
¶
Index ¶
- func Names() []string
- func Register(name string, ctr func() Reporter) error
- type DefaultReporter
- func (r *DefaultReporter) Init(c *client.Config)
- func (r *DefaultReporter) JobstepAPIPath() string
- func (r *DefaultReporter) PushSnapshotImageStatus(imgID string, status string) error
- func (r *DefaultReporter) ReportMetrics(metrics client.Metrics)
- func (r *DefaultReporter) SendPayload(rp ReportPayload) error
- func (r *DefaultReporter) Shutdown()
- type NoopReporter
- func (noop *NoopReporter) Init(_ *client.Config)
- func (noop *NoopReporter) PublishArtifacts(_ client.ConfigCmd, _ adapter.Adapter, _ *client.Log) error
- func (noop *NoopReporter) PushCommandOutput(_, _ string, _ int, _ []byte)
- func (noop *NoopReporter) PushCommandStatus(_, _ string, _ int)
- func (noop *NoopReporter) PushJobstepStatus(_, _ string)
- func (noop *NoopReporter) PushLogChunk(_ string, _ []byte) bool
- func (noop *NoopReporter) PushSnapshotImageStatus(_, _ string) error
- func (noop *NoopReporter) ReportMetrics(_ client.Metrics)
- func (noop *NoopReporter) Shutdown()
- type Registry
- type ReportPayload
- type Reporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DefaultReporter ¶
type DefaultReporter struct { // Note that this is not safe to send to after Shutdown() is called. PublishChannel chan ReportPayload // contains filtered or unexported fields }
With each reporter there is a goroutine associated with it that listens to PublishChannel and shutdownChannel, publishing all data from PublishChannel to the publishUri for the jobstepID associated with the current build. Sending any information to shutdownChannel causes the goroutine to stop.
Notably this means that all of the methods in this module are asynchronous and as a result there is a delay between them successfully finishing and Changes actually acknowledging them at the endpoint. More importantly, however, because the requests are sent in a separate goroutine, the methods here may succeed even when the endpoing requests fail.
func (*DefaultReporter) Init ¶
func (r *DefaultReporter) Init(c *client.Config)
func (*DefaultReporter) JobstepAPIPath ¶
func (r *DefaultReporter) JobstepAPIPath() string
func (*DefaultReporter) PushSnapshotImageStatus ¶
func (r *DefaultReporter) PushSnapshotImageStatus(imgID string, status string) error
func (*DefaultReporter) ReportMetrics ¶
func (r *DefaultReporter) ReportMetrics(metrics client.Metrics)
func (*DefaultReporter) SendPayload ¶
func (r *DefaultReporter) SendPayload(rp ReportPayload) error
Utility method for sending a payload. This wraps httpPost in a framework nicer for the Reporter itself, as it turns the ReportPayload into its associated params (which corresponds to its data). We also attempt httpPost multiple times in order to account for flakiness in the network connection. This function is synchronous.
func (*DefaultReporter) Shutdown ¶
func (r *DefaultReporter) Shutdown()
Close the publish and shutdown channels, which causes the inner goroutines to terminate, thus cleaning up what is created by Init.
type NoopReporter ¶
type NoopReporter struct{}
func (*NoopReporter) Init ¶
func (noop *NoopReporter) Init(_ *client.Config)
func (*NoopReporter) PublishArtifacts ¶
func (*NoopReporter) PushCommandOutput ¶
func (noop *NoopReporter) PushCommandOutput(_, _ string, _ int, _ []byte)
func (*NoopReporter) PushCommandStatus ¶
func (noop *NoopReporter) PushCommandStatus(_, _ string, _ int)
func (*NoopReporter) PushJobstepStatus ¶
func (noop *NoopReporter) PushJobstepStatus(_, _ string)
func (*NoopReporter) PushLogChunk ¶
func (noop *NoopReporter) PushLogChunk(_ string, _ []byte) bool
func (*NoopReporter) PushSnapshotImageStatus ¶
func (noop *NoopReporter) PushSnapshotImageStatus(_, _ string) error
func (*NoopReporter) ReportMetrics ¶
func (noop *NoopReporter) ReportMetrics(_ client.Metrics)
func (*NoopReporter) Shutdown ¶
func (noop *NoopReporter) Shutdown()
type ReportPayload ¶
type ReportPayload struct { Path string // A map of fields to their values. Note that the date field // will be automatically set when the data is sent. Data map[string]string Filename string }
All data that goes to the server is encompassed in a payload.
type Reporter ¶
type Reporter interface { Init(config *client.Config) Shutdown() // This function is not required to be synchronous, but it must do // something that will cause the artifacts to be published in the future. // In the case of Jenkins reporter builds, it moves the artifacts to a // location known by Jenkins, and considers these artifacts to be reported // as it relies on Jenkins to later pull those artifacts and send them to // Changes. Mesos sends the artifacts in a separate goroutine, so neither // reporter immediately publishes the artifacts. // // Jenkins and Mesos also take different approaches to detecting artifacts, // so this function is responsible for this as well. For Mesos builds, each // command lists the artifacts it is expected to return, but Jenkins builds // are expected to return any artifact within a folder. Since the detection // is different for each reporter and each detection relies on the adapter // to figure out where to actually look for files, a reference to the adapter // is required here. PublishArtifacts(cmd client.ConfigCmd, adapter adapter.Adapter, clientLog *client.Log) error PushSnapshotImageStatus(imgID string, status string) error // These are optional, implement empty functions to just not provide // this functionality as a reporter (ie, Jenkins). However it should // be noted that if no other machinery provides this functionality // (as is the case for Mesos builds) then these are absolutely required // as without them Changes will never receive updates. PushCommandStatus(cID string, status string, retCode int) PushCommandOutput(cID string, status string, retCode int, output []byte) PushJobstepStatus(status string, result string) // returns false if pushing the log chunk failed PushLogChunk(source string, payload []byte) bool // Report any collected metrics. This is optional, but can be used to e.g. // send metrics to Changes. ReportMetrics(metrics client.Metrics) }
An abstract way of communicating things to Changes.