Ejemplo n.º 1
0
// SSE is a method for actions.SSE
func (action *OperationIndexAction) SSE(stream sse.Stream) {
	action.LoadRecords()

	if action.Err != nil {
		stream.Err(action.Err)
		return
	}

	records := action.Records[stream.SentCount():]

	for _, record := range records {
		r, err := NewOperationResource(record)

		if err != nil {
			stream.Err(action.Err)
			return
		}

		stream.Send(sse.Event{
			ID:   record.PagingToken(),
			Data: r,
		})
	}

	if stream.SentCount() >= int(action.Query.Limit) {
		stream.Done()
	}
}
Ejemplo n.º 2
0
// SSE is a method for actions.SSE
func (action *AccountShowAction) SSE(stream sse.Stream) {
	action.LoadRecord()
	if action.Err != nil {
		stream.Err(action.Err)
		return
	}

	stream.Send(sse.Event{
		Data: NewAccountResource(action.Record),
	})

	if stream.SentCount() >= 10 {
		stream.Done()
	}
}
Ejemplo n.º 3
0
// SSE is a method for actions.SSE
func (action *OrderBookShowAction) SSE(stream sse.Stream) {
	action.Do(action.LoadQuery, action.LoadRecord, action.LoadResource)
	if action.Err != nil {
		stream.Err(action.Err)
		return
	}

	stream.Send(sse.Event{
		Data: action.Resource,
	})

	if stream.SentCount() >= 10 {
		stream.Done()
	}
}
Ejemplo n.º 4
0
// SSE is a method for actions.SSE
func (action *AccountIndexAction) SSE(stream sse.Stream) {
	action.LoadRecords()
	if action.Err != nil {
		stream.Err(action.Err)
		return
	}

	for _, record := range action.Records[stream.SentCount():] {
		stream.Send(sse.Event{
			ID:   record.PagingToken(),
			Data: NewHistoryAccountResource(record),
		})
	}

	if stream.SentCount() >= int(action.Query.Limit) {
		stream.Done()
	}
}