func (s *apiServer) Events(r *types.EventsRequest, stream types.API_EventsServer) error { t := time.Time{} if r.Timestamp != nil { from, err := ptypes.Timestamp(r.Timestamp) if err != nil { return err } t = from } events := s.sv.Events.Events(t) defer s.sv.Events.Unsubscribe(events) for e := range events { tsp, err := ptypes.TimestampProto(e.Timestamp) if err != nil { return err } if err := stream.Send(&types.Event{ Id: e.ID, Type: e.Type, Timestamp: tsp, Pid: e.PID, Status: uint32(e.Status), }); err != nil { return err } } return nil }
func (s *apiServer) Events(r *types.EventsRequest, stream types.API_EventsServer) error { events := s.sv.Events() defer s.sv.Unsubscribe(events) for evt := range events { var ev *types.Event switch evt.Type { case supervisor.ExitEventType, supervisor.ExecExitEventType: ev = &types.Event{ Type: "exit", Id: evt.ID, Pid: uint32(evt.Pid), Status: uint32(evt.Status), } case supervisor.OOMEventType: ev = &types.Event{ Type: "oom", Id: evt.ID, } } if ev != nil { if err := stream.Send(ev); err != nil { return err } } } return nil }
func (s *apiServer) Events(r *types.EventsRequest, stream types.API_EventsServer) error { t := time.Time{} if r.Timestamp != nil { from, err := ptypes.Timestamp(r.Timestamp) if err != nil { return err } t = from } if r.StoredOnly && t.IsZero() { return fmt.Errorf("invalid parameter: StoredOnly cannot be specified without setting a valid Timestamp") } events := s.sv.Events(t, r.StoredOnly, r.Id) defer s.sv.Unsubscribe(events) for e := range events { tsp, err := ptypes.TimestampProto(e.Timestamp) if err != nil { return err } if r.Id == "" || e.ID == r.Id { if err := stream.Send(&types.Event{ Id: e.ID, Type: e.Type, Timestamp: tsp, Pid: e.PID, Status: uint32(e.Status), }); err != nil { return err } } } return nil }
func (s *apiServer) Events(r *types.EventsRequest, stream types.API_EventsServer) error { t := time.Time{} if r.Timestamp != 0 { t = time.Unix(int64(r.Timestamp), 0) } events := s.sv.Events(t) defer s.sv.Unsubscribe(events) for e := range events { if err := stream.Send(&types.Event{ Id: e.ID, Type: e.Type, Timestamp: uint64(e.Timestamp.Unix()), Pid: e.PID, Status: uint32(e.Status), }); err != nil { return err } } return nil }