Пример #1
0
func (client *client) BuildEvents(buildID string) (Events, error) {
	sseEvents, err := client.connection.ConnectToEventStream(internal.Request{
		RequestName: atc.BuildEvents,
		Params:      rata.Params{"build_id": buildID},
	})
	if err != nil {
		return nil, err
	}

	return eventstream.NewSSEEventStream(sseEvents), nil
}
Пример #2
0
func RenderStream(eventSource *sse.EventSource) (int, error) {
	return Render(os.Stdout, eventstream.NewSSEEventStream(eventSource)), nil
}
Пример #3
0
			}

			atcServer.AppendHandlers(
				eventsHandler(),
			)
		})

		It("returns an EventSource that can stream events", func() {
			eventSource, err := connection.ConnectToEventStream(
				Request{
					RequestName: atc.BuildEvents,
					Params:      rata.Params{"build_id": buildID},
				})
			Expect(err).NotTo(HaveOccurred())

			events := eventstream.NewSSEEventStream(eventSource)

			Eventually(streaming).Should(BeClosed())

			eventsChan <- event.Log{Payload: "sup"}

			nextEvent, err := events.NextEvent()
			Expect(err).NotTo(HaveOccurred())
			Expect(nextEvent).To(Equal(event.Log{Payload: "sup"}))

			close(eventsChan)

			_, err = events.NextEvent()
			Expect(err).To(MatchError(io.EOF))
		})
	})