本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.Envelope_EventType函数的典型用法代码示例。如果您正苦于以下问题:Golang Envelope_EventType函数的具体用法?Golang Envelope_EventType怎么用?Golang Envelope_EventType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Envelope_EventType函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
metricNames = make(map[events.Envelope_EventType]string)
for eventType, eventName := range events.Envelope_EventType_name {
r, n := utf8.DecodeRuneInString(eventName)
modifiedName := string(unicode.ToLower(r)) + eventName[n:]
metricName := "dropsondeMarshaller." + modifiedName + "Marshalled"
metricNames[events.Envelope_EventType(eventType)] = metricName
}
}
开发者ID:hpcloud,项目名称:loggregator-1,代码行数:9,代码来源:doppler_forwarder.go
示例2: NewDropsondeMarshaller
// NewDropsondeMarshaller instantiates a DropsondeMarshaller and logs to the
// provided logger.
func NewDropsondeMarshaller(logger *gosteno.Logger) DropsondeMarshaller {
messageCounts := make(map[events.Envelope_EventType]*uint64)
for key := range events.Envelope_EventType_name {
var count uint64
messageCounts[events.Envelope_EventType(key)] = &count
}
return &dropsondeMarshaller{
logger: logger,
messageCounts: messageCounts,
}
}
开发者ID:Reejoshi,项目名称:cli,代码行数:13,代码来源:dropsonde_marshaller.go
示例3: New
// New instantiates a EventMarshaller and logs to the provided logger.
func New(outputWriter writers.ByteArrayWriter, logger *gosteno.Logger) *EventMarshaller {
messageCounts := make(map[events.Envelope_EventType]*uint64)
for key := range events.Envelope_EventType_name {
var count uint64
messageCounts[events.Envelope_EventType(key)] = &count
}
return &EventMarshaller{
logger: logger,
outputWriter: outputWriter,
messageCounts: messageCounts,
}
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:13,代码来源:event_marshaller.go
示例4: New
// New instantiates a EventUnmarshaller and logs to the
// provided logger.
func New(outputWriter writers.EnvelopeWriter, logger *gosteno.Logger) *EventUnmarshaller {
receiveCounts := make(map[events.Envelope_EventType]*uint64)
for key := range events.Envelope_EventType_name {
var count uint64
receiveCounts[events.Envelope_EventType(key)] = &count
}
return &EventUnmarshaller{
logger: logger,
outputWriter: outputWriter,
receiveCounts: receiveCounts,
}
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:15,代码来源:event_unmarshaller.go
示例5: NewDropsondeUnmarshaller
// NewDropsondeUnmarshaller instantiates a DropsondeUnmarshaller and logs to the
// provided logger.
func NewDropsondeUnmarshaller(logger *gosteno.Logger) DropsondeUnmarshaller {
receiveCounts := make(map[events.Envelope_EventType]*uint64)
for key := range events.Envelope_EventType_name {
var count uint64
receiveCounts[events.Envelope_EventType(key)] = &count
}
return &dropsondeUnmarshaller{
logger: logger,
receiveCounts: receiveCounts,
logMessageReceiveCounts: make(map[string]*uint64),
}
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:15,代码来源:dropsonde_unmarshaller.go
示例6: metrics
func (m *EventMarshaller) metrics() []instrumentation.Metric {
var metrics []instrumentation.Metric
for eventType, eventName := range events.Envelope_EventType_name {
modifiedEventName := []rune(eventName)
modifiedEventName[0] = unicode.ToLower(modifiedEventName[0])
metricName := string(modifiedEventName) + "Marshalled"
metricValue := atomic.LoadUint64(m.messageCounts[events.Envelope_EventType(eventType)])
metrics = append(metrics, instrumentation.Metric{Name: metricName, Value: metricValue})
}
metrics = append(metrics, instrumentation.Metric{
Name: "marshalErrors",
Value: atomic.LoadUint64(&m.marshalErrorCount),
})
return metrics
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:19,代码来源:event_marshaller.go
示例7:
go tlsListener.Start()
})
AfterEach(func() {
tlsListener.Stop()
})
Context("dropsonde metric emission", func() {
BeforeEach(func() {
fakeEventEmitter.Reset()
metricBatcher.Reset()
})
It("sends all types of messages as a protobuf", func() {
for name, eventType := range events.Envelope_EventType_value {
envelope := createEnvelope(events.Envelope_EventType(eventType))
conn := openTLSConnection(tlsListener.Address())
err := send(conn, envelope)
Expect(err).ToNot(HaveOccurred())
Eventually(envelopeChan).Should(Receive(Equal(envelope)), fmt.Sprintf("did not receive expected event: %s", name))
conn.Close()
}
})
It("sends all types of messages over multiple connections", func() {
for _, eventType := range events.Envelope_EventType_value {
envelope1 := createEnvelope(events.Envelope_EventType(eventType))
conn1 := openTLSConnection(tlsListener.Address())
开发者ID:nagyistoce,项目名称:cloudfoundry-loggregator,代码行数:30,代码来源:tls_listener_test.go
示例8:
It("unmarshalls bytes", func() {
output, _ := unmarshaller.UnmarshallMessage(message)
Expect(output).To(Equal(event))
})
It("handles bad input gracefully", func() {
output, err := unmarshaller.UnmarshallMessage(make([]byte, 4))
Expect(output).To(BeNil())
Expect(err).To(HaveOccurred())
})
It("doesn't write unknown event types", func() {
unknownEventTypeMessage := &events.Envelope{
Origin: proto.String("fake-origin-2"),
EventType: events.Envelope_EventType(2000).Enum(),
ValueMetric: &events.ValueMetric{
Name: proto.String("fake-metric-name"),
Value: proto.Float64(42),
Unit: proto.String("fake-unit"),
},
}
message, err := proto.Marshal(unknownEventTypeMessage)
Expect(err).ToNot(HaveOccurred())
output, err := unmarshaller.UnmarshallMessage(message)
Expect(output).To(BeNil())
Expect(err).To(HaveOccurred())
})
})
开发者ID:Jonty,项目名称:loggregator,代码行数:30,代码来源:event_unmarshaller_test.go
示例9:
. "github.com/onsi/gomega"
)
var _ = Describe("BufferContext", func() {
Context("DefaultContext", func() {
var defaultContext *DefaultContext
BeforeEach(func() {
defaultContext = NewDefaultContext("origin", "testIdentifier")
})
It("Should return a valid properties", func() {
Expect(defaultContext.Origin()).To(Equal("origin"))
Expect(defaultContext.Destination()).To(Equal("testIdentifier"))
for _, event := range events.Envelope_EventType_value {
Expect(defaultContext.EventAllowed(events.Envelope_EventType(event))).To(BeTrue())
}
message := factories.NewLogMessage(events.LogMessage_OUT, "hello", "appID", "source")
envelope := &events.Envelope{
Origin: proto.String("origin"),
EventType: events.Envelope_LogMessage.Enum(),
LogMessage: message,
}
Expect(defaultContext.AppID(envelope)).To(Equal("appID"))
})
})
Context("LogAllowedContext", func() {
var logAllowedContext *LogAllowedContext
开发者ID:sunatthegilddotcom,项目名称:loggregator,代码行数:30,代码来源:buffer_context_test.go
示例10:
Origin: proto.String("MetronAgent"),
EventType: events.Envelope_CounterEvent.Enum(),
CounterEvent: &events.CounterEvent{
Name: proto.String("dropsondeUnmarshaller.logMessageTotal"),
Delta: proto.Uint64(1),
Total: proto.Uint64(1),
},
}
Eventually(testDoppler.MessageChan, 2).Should(Receive(MatchSpecifiedContents(&expected)))
})
It("counts unknown event types", func() {
metronInput, _ := net.Dial("udp4", "localhost:51161")
message := basicValueMessageEnvelope()
message.EventType = events.Envelope_EventType(2000).Enum()
bytes, err := proto.Marshal(message)
Expect(err).ToNot(HaveOccurred())
metronInput.Write(bytes)
message = basicValueMessageEnvelope()
badEventType := events.Envelope_EventType(1000)
message.EventType = &badEventType
bytes, err = proto.Marshal(message)
Expect(err).ToNot(HaveOccurred())
metronInput.Write(bytes)
expected := events.Envelope{
Origin: proto.String("MetronAgent"),
开发者ID:Amit-PivotalLabs,项目名称:loggregator,代码行数:31,代码来源:self_instrumentation_test.go
示例11:
})
It("emits a value metric counter", func() {
envelope := &events.Envelope{
Origin: proto.String("fake-origin-3"),
EventType: events.Envelope_ValueMetric.Enum(),
ValueMetric: factories.NewValueMetric("value-name", 1.0, "units"),
}
inputChan <- envelope
eventuallyExpectCounter("dropsondeMarshaller.valueMetricReceived", 1)
})
It("counts unknown message types", func() {
unexpectedMessageType := events.Envelope_EventType(1)
envelope1 := &events.Envelope{
Origin: proto.String("fake-origin-3"),
EventType: &unexpectedMessageType,
LogMessage: factories.NewLogMessage(events.LogMessage_OUT, "test log message 1", "fake-app-id-1", "DEA"),
}
inputChan <- envelope1
eventuallyExpectCounter("dropsondeMarshaller.unknownEventTypeReceived", 1)
})
Context("when a http start stop message is received", func() {
It("emits a counter message with a delta value of 1", func() {
envelope := &events.Envelope{
Origin: proto.String("fake-origin-1"),
开发者ID:fraenkel,项目名称:dropsonde,代码行数:31,代码来源:dropsonde_marshaller_test.go
示例12: String
func (e *eventTypeValue) String() string {
return events.Envelope_EventType(*e).String()
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:3,代码来源:main.go
注:本文中的github.com/cloudfoundry/sonde-go/events.Envelope_EventType函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论