// Events returns a channel of *GoEvtxMap
// return (chan *GoEvtxMap)
180047
func (c *Chunk) Events() (cgem chan *GoEvtxMap) {
	// Unbuffered Event channel
	cgem = make(chan *GoEvtxMap, len(c.EventOffsets))
	go func() {
		defer close(cgem)
		for _, eo := range c.EventOffsets {
			// for every event offset, we parsed the event at that position
			event := c.ParseEvent(int64(eo))
			gem, err := event.GoEvtxMap(c)
			if err == nil {
				cgem <- gem
			}
		}
	}()
	return
}
905427
func (az *Cloud) Event(obj runtime.Object, eventtype, reason, message string) {
	if obj != nil && reason != "" {
		az.eventRecorder.Event(obj, eventtype, reason, message)
	}
}
1112654
func (factory *OpenweathermapBeeFactory) Events() []bees.EventDescriptor {
	events := []bees.EventDescriptor{
		{
			Namespace:   factory.Name(),
			Name:        "current_weather",
			Description: "Current weather holds measurement informations",
			Options: []bees.PlaceholderDescriptor{
				{
					Name:        "geo_pos_longitude",
					Type:        "float64",
					Description: "Geo position longitude",
				},
				{
					Name:        "geo_pos_latitude",
					Type:        "float64",
					Description: "Geo position latitude",
				},
				{
					Name:        "sys_type",
					Type:        "int",
					Description: "sys type",
				},
				{
					Name:        "sys_id",
					Type:        "int",
					Description: "sys ID",
				},
				{
					Name:        "sys_message",
					Type:        "float64",
					Description: "sys message",
				},
				{
					Name:        "sys_country",
					Type:        "string",
					Description: "sys country code",
				},
				{
					Name:        "sys_sunrise",
					Type:        "int",
					Description: "sys sunrise",
				},
				{
					Name:        "sys_sunset",
					Type:        "int",
					Description: "sys sunset",
				},
				{
					Name:        "base",
					Type:        "string",
					Description: "current weather base",
				},
				{
					Name:        "main_temp",
					Type:        "float64",
					Description: "current main temperature",
				},
				{
					Name:        "main_temp_min",
					Type:        "float64",
					Description: "current main minimum temperature",
				},
				{
					Name:        "main_temp_max",
					Type:        "float64",
					Description: "current main maximum temperature",
				},
				{
					Name:        "main_pressure",
					Type:        "float64",
					Description: "current air pressure",
				},
				{
					Name:        "main_sealevel",
					Type:        "float64",
					Description: "current sealevel",
				},
				{
					Name:        "main_grndlevel",
					Type:        "float64",
					Description: "current groundlevel",
				},
				{
					Name:        "main_humidity",
					Type:        "float64",
					Description: "main humidity",
				},
				{
					Name:        "wind_speed",
					Type:        "float64",
					Description: "wind speed",
				},
				{
					Name:        "wind_deg",
					Type:        "float64",
					Description: "wind degree",
				},
				{
					Name:        "clouds_all",
					Type:        "int",
					Description: "clouds",
				},
				{
					Name:        "rain",
					Type:        "map[string]float64",
					Description: "rain",
				},
				{
					Name:        "snow",
					Type:        "map[string]float64",
					Description: "snow",
				},
				{
					Name:        "dt",
					Type:        "int",
					Description: "dt",
				},
				{
					Name:        "id",
					Type:        "int",
					Description: "id",
				},
				{
					Name:        "name",
					Type:        "string",
					Description: "name",
				},
				{
					Name:        "cod",
					Type:        "int",
					Description: "cod",
				},
				{
					Name:        "unit",
					Type:        "string",
					Description: "unit meassurement system",
				},
				{
					Name:        "lang",
					Type:        "string",
					Description: "language",
				},
				{
					Name:        "key",
					Type:        "string",
					Description: "key",
				},
			},
		},
		{
			Namespace:   factory.Name(),
			Name:        "main_weather",
			Description: "returns main measurement weather informations",
			Options: []bees.PlaceholderDescriptor{
				{
					Name:        "id",
					Type:        "int",
					Description: "weather id",
				},
				{
					Name:        "main",
					Type:        "string",
					Description: "main weather information",
				},
				{
					Name:        "description",
					Type:        "string",
					Description: "current weather main description",
				},
				{
					Name:        "icon",
					Type:        "string",
					Description: "weather icon",
				},
			},
		},
	}
	return events
}
56433
func (sm *StateMachine) Event(name string) *Event {
	event := &Event{Name: name}
	sm.events[name] = event
	return event
}
1293602
func (s *ClientConfigChangerSink) AddEvents(ctx context.Context, events []*event.Event) error {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.Destination.AddEvents(ctx, events)
}
291522
func (s *ServicesTestSuite) Events(c *check.C) {
	testCases := []eventTest{
		{
			name: "Cert authority with secrets",
			kind: services.WatchKind{
				Kind:        services.KindCertAuthority,
				LoadSecrets: true,
			},
			crud: func() services.Resource {
				ca := NewTestCA(services.UserCA, "example.com")
				c.Assert(s.CAS.UpsertCertAuthority(ca), check.IsNil)

				out, err := s.CAS.GetCertAuthority(*ca.ID(), true)
				c.Assert(err, check.IsNil)

				c.Assert(s.CAS.DeleteCertAuthority(*ca.ID()), check.IsNil)
				return out
			},
		},
	}
	s.runEventsTests(c, testCases)

	testCases = []eventTest{
		{
			name: "Cert authority without secrets",
			kind: services.WatchKind{
				Kind:        services.KindCertAuthority,
				LoadSecrets: false,
			},
			crud: func() services.Resource {
				ca := NewTestCA(services.UserCA, "example.com")
				c.Assert(s.CAS.UpsertCertAuthority(ca), check.IsNil)

				out, err := s.CAS.GetCertAuthority(*ca.ID(), false)
				c.Assert(err, check.IsNil)

				c.Assert(s.CAS.DeleteCertAuthority(*ca.ID()), check.IsNil)
				return out
			},
		},
	}
	s.runEventsTests(c, testCases)

	testCases = []eventTest{
		{
			name: "Token",
			kind: services.WatchKind{
				Kind: services.KindToken,
			},
			crud: func() services.Resource {
				expires := time.Now().UTC().Add(time.Hour)
				t, err := services.NewProvisionToken("token",
					teleport.Roles{teleport.RoleAuth, teleport.RoleNode}, expires)
				c.Assert(err, check.IsNil)

				c.Assert(s.ProvisioningS.UpsertToken(t), check.IsNil)

				token, err := s.ProvisioningS.GetToken("token")
				c.Assert(err, check.IsNil)

				c.Assert(s.ProvisioningS.DeleteToken("token"), check.IsNil)
				return token
			},
		},
		{
			name: "Namespace",
			kind: services.WatchKind{
				Kind: services.KindNamespace,
			},
			crud: func() services.Resource {
				ns := services.Namespace{
					Kind:    services.KindNamespace,
					Version: services.V2,
					Metadata: services.Metadata{
						Name:      "testnamespace",
						Namespace: defaults.Namespace,
					},
				}
				err := s.PresenceS.UpsertNamespace(ns)
				c.Assert(err, check.IsNil)

				out, err := s.PresenceS.GetNamespace(ns.Metadata.Name)
				c.Assert(err, check.IsNil)

				err = s.PresenceS.DeleteNamespace(ns.Metadata.Name)
				c.Assert(err, check.IsNil)

				return out
			},
		},
		{
			name: "Static tokens",
			kind: services.WatchKind{
				Kind: services.KindStaticTokens,
			},
			crud: func() services.Resource {
				staticTokens, err := services.NewStaticTokens(services.StaticTokensSpecV2{
					StaticTokens: []services.ProvisionTokenV1{
						{
							Token:   "tok1",
							Roles:   teleport.Roles{teleport.RoleNode},
							Expires: time.Now().UTC().Add(time.Hour),
						},
					},
				})
				c.Assert(err, check.IsNil)

				err = s.ConfigS.SetStaticTokens(staticTokens)
				c.Assert(err, check.IsNil)

				out, err := s.ConfigS.GetStaticTokens()
				c.Assert(err, check.IsNil)

				err = s.ConfigS.DeleteStaticTokens()
				c.Assert(err, check.IsNil)

				return out
			},
		},
		{
			name: "Role",
			kind: services.WatchKind{
				Kind: services.KindRole,
			},
			crud: func() services.Resource {
				role, err := services.NewRole("role1", services.RoleSpecV3{
					Options: services.RoleOptions{
						MaxSessionTTL: services.Duration(time.Hour),
					},
					Allow: services.RoleConditions{
						Logins:     []string{"root", "bob"},
						NodeLabels: services.Labels{services.Wildcard: []string{services.Wildcard}},
					},
					Deny: services.RoleConditions{},
				})

				err = s.Access.UpsertRole(role)
				c.Assert(err, check.IsNil)

				out, err := s.Access.GetRole(role.GetName())
				c.Assert(err, check.IsNil)

				err = s.Access.DeleteRole(role.GetName())
				c.Assert(err, check.IsNil)

				return out
			},
		},
		{
			name: "User",
			kind: services.WatchKind{
				Kind: services.KindUser,
			},
			crud: func() services.Resource {
				user := newUser("user1", []string{"admin"})
				err := s.Users().UpsertUser(user)

				out, err := s.Users().GetUser(user.GetName())
				c.Assert(err, check.IsNil)

				c.Assert(s.Users().DeleteUser(user.GetName()), check.IsNil)
				return out
			},
		},
		{
			name: "Node",
			kind: services.WatchKind{
				Kind: services.KindNode,
			},
			crud: func() services.Resource {
				srv := NewServer(services.KindNode, "srv1", "127.0.0.1:2022", defaults.Namespace)

				_, err := s.PresenceS.UpsertNode(srv)
				c.Assert(err, check.IsNil)

				out, err := s.PresenceS.GetNodes(srv.Metadata.Namespace)
				c.Assert(err, check.IsNil)

				err = s.PresenceS.DeleteAllNodes(srv.Metadata.Namespace)
				c.Assert(err, check.IsNil)

				return out[0]
			},
		},
		{
			name: "Proxy",
			kind: services.WatchKind{
				Kind: services.KindProxy,
			},
			crud: func() services.Resource {
				srv := NewServer(services.KindProxy, "srv1", "127.0.0.1:2022", defaults.Namespace)

				err := s.PresenceS.UpsertProxy(srv)
				c.Assert(err, check.IsNil)

				out, err := s.PresenceS.GetProxies()
				c.Assert(err, check.IsNil)

				err = s.PresenceS.DeleteAllProxies()
				c.Assert(err, check.IsNil)

				return out[0]
			},
		},
		{
			name: "Tunnel connection",
			kind: services.WatchKind{
				Kind: services.KindTunnelConnection,
			},
			crud: func() services.Resource {
				conn, err := services.NewTunnelConnection("conn1", services.TunnelConnectionSpecV2{
					ClusterName:   "example.com",
					ProxyName:     "p1",
					LastHeartbeat: time.Now().UTC(),
				})
				c.Assert(err, check.IsNil)

				err = s.PresenceS.UpsertTunnelConnection(conn)
				c.Assert(err, check.IsNil)

				out, err := s.PresenceS.GetTunnelConnections("example.com")
				c.Assert(err, check.IsNil)

				err = s.PresenceS.DeleteAllTunnelConnections()
				c.Assert(err, check.IsNil)

				return out[0]
			},
		},
		{
			name: "Reverse tunnel",
			kind: services.WatchKind{
				Kind: services.KindReverseTunnel,
			},
			crud: func() services.Resource {
				tunnel := newReverseTunnel("example.com", []string{"example.com:2023"})
				c.Assert(s.PresenceS.UpsertReverseTunnel(tunnel), check.IsNil)

				out, err := s.PresenceS.GetReverseTunnels()
				c.Assert(err, check.IsNil)

				err = s.PresenceS.DeleteReverseTunnel(tunnel.Spec.ClusterName)
				c.Assert(err, check.IsNil)

				return out[0]
			},
		},
	}
	s.runEventsTests(c, testCases)

	// Namespace with a name
	testCases = []eventTest{
		{
			name: "Namespace with a name",
			kind: services.WatchKind{
				Kind: services.KindNamespace,
				Name: "shmest",
			},
			crud: func() services.Resource {
				ns := services.Namespace{
					Kind:    services.KindNamespace,
					Version: services.V2,
					Metadata: services.Metadata{
						Name:      "shmest",
						Namespace: defaults.Namespace,
					},
				}
				err := s.PresenceS.UpsertNamespace(ns)
				c.Assert(err, check.IsNil)

				out, err := s.PresenceS.GetNamespace(ns.Metadata.Name)
				c.Assert(err, check.IsNil)

				err = s.PresenceS.DeleteNamespace(ns.Metadata.Name)
				c.Assert(err, check.IsNil)

				return out
			},
		},
	}
	s.runEventsTests(c, testCases)
}
293101
func event(out io.Writer) {
	event_h := readHeader("event")

	// Event is implemented by hand in wrappers.go

	// Get all the pn_event_type_t enum values
	var etypes []eventType
	enums := findEnums(event_h)
	for _, e := range enums[0].Values {
		if skipEventRe.FindStringSubmatch(e) == nil {
			etypes = append(etypes, newEventType(e))
		}
	}

	doTemplate(out, etypes, `
type EventType int
const ({{range .}}
	 E{{.Name}} EventType = C.{{.Cname}}{{end}}
)
`)

	doTemplate(out, etypes, `
func (e EventType) String() string {
	switch e {
{{range .}}
	case C.{{.Cname}}: return "{{.Name}}"{{end}}
	}
	return "Unknown"
}
`)
}
1349683
func (s *EventService) ListEvents(p *ListEventsParams) (*ListEventsResponse, error) {
	resp, err := s.cs.newRequest("listEvents", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListEventsResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1174698
func (r *Recorder) Events() []Event {
	r.lock.Lock()
	defer r.lock.Unlock()
	copied := make([]Event, len(r.events))
	copy(copied, r.events)
	return copied
}
139579
func (ef *File) MonitorEvents(stop chan bool, sleep ...time.Duration) (cgem chan *GoEvtxMap) {
	// Normally, it should not be needed to add a second check here on the
	// EventRecordID since the record ids in the chunks are not supposed to overlap
	// TODO: Add a EventRecordID marker if needed
	sleepTime := DefaultMonitorSleep
	if len(sleep) > 0 {
		sleepTime = sleep[0]
	}
	jobs := MaxJobs
	cgem = make(chan *GoEvtxMap, 42)
	go func() {
		defer close(cgem)
		chanQueue := make(chan (chan *GoEvtxMap), jobs)
		go func() {
			defer close(chanQueue)
			// this chan ends only when value is put into stop
			for pc := range ef.monitorChunks(stop, sleepTime) {
				// We have to create a copy here because otherwise cpc.EventsChan() fails
				// I guess that because EventsChan takes a pointer to an object
				// and thus the chan is taken on the pointer and since the object pointed
				// changes -> kaboom
				cpc := pc
				ev := cpc.Events()
				chanQueue <- ev
			}
		}()
		for ec := range chanQueue {
			for event := range ec {
				cgem <- event
			}
		}
	}()
	return
}
216278
func (c *Client) SendEvents(events []Event, opts ...interface{}) (res StatusMessageRes, err error) {
	body := newSendEventsReq(events)
	err = c.transport.Request(&res, http.MethodPost, "/1/events", body, call.Write, opts...)
	return
}
962663
func (a *EventCounter) Events(now time.Time, count int64) int64 {
	for {
		nsSince := now.Sub(a.startingTime).Nanoseconds()
		prevNsSinceStart := atomic.LoadInt64(&a.nsSinceStart)
		if nsSince-prevNsSinceStart >= a.eventDuration.Nanoseconds() {
			//		 Note: There is an accepted race here when we transition states that could cause us to
			//		       rarely miss an event that crosses the threshold.  This is an accepted aspect of
			//		       having a very fast non threshold event
			if atomic.CompareAndSwapInt64(&a.nsSinceStart, prevNsSinceStart, nsSince) {
				atomic.StoreInt64(&a.eventsThisPeriod, 0)
				break
			}
		} else {
			break
		}
	}
	return atomic.AddInt64(&a.eventsThisPeriod, count)
}
692254
func (c *GorymanClient) QueryEvents(q string) ([]Event, error) {
	query := &proto.Query{}
	query.String_ = pb.String(q)

	message := &proto.Msg{}
	message.Query = query

	response, err := c.sendRecv(message)
	if err != nil {
		return nil, err
	}

	return ProtocolBuffersToEvents(response.GetEvents()), nil
}
180896
func AsyncEvents(e EventStream) EventStream {
	s := &asyncEventStream{
		e:      e,
		events: make(chan Event, 100),
	}
	go s.start()
	return s
}
694171
func (me *Event) C() <-chan struct{} {
	if me.ch == nil {
		me.ch = make(chan struct{})
	}
	return me.ch
}
178309
func (h *HTTPSink) AddEvents(ctx context.Context, events []*event.Event) (err error) {
	if len(events) == 0 || h.EventEndpoint == "" {
		return nil
	}
	return h.doBottom(ctx, func() (io.Reader, bool, error) {
		return h.encodePostBodyProtobufV2Events(events)
	}, "application/x-protobuf", h.EventEndpoint, datapointAndEventResponseValidator)
}
892028
func ParseEvents(raw []events.RawJSON) ([]Event, error) {
	var result []Event
	for _, value := range raw {
		event, err := ParseEvent(value)
		if err != nil {
			return nil, fmt.Errorf("while parsing event: %s", err)
		}
		result = append(result, event)
	}
	return result, nil
}