Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
3d5b474c
Commit
3d5b474c
authored
3 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
EventCallbackFunction moved to interfaces package
parent
468b221f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!23
Release
,
!13
Hotfix/no host cooldown + return sende2e TS
,
!11
Client Event Reporting API
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/event.go
+4
-6
4 additions, 6 deletions
api/event.go
bindings/event.go
+2
-2
2 additions, 2 deletions
bindings/event.go
interfaces/event.go
+11
-0
11 additions, 0 deletions
interfaces/event.go
with
17 additions
and
8 deletions
api/event.go
+
4
−
6
View file @
3d5b474c
...
...
@@ -11,13 +11,11 @@ import (
"fmt"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/stoppable"
"sync"
)
// EventCallbackFunction defines the callback functions for client event reports
type
EventCallbackFunction
func
(
priority
int
,
category
,
evtType
,
details
string
)
// ReportableEvent is used to surface events to client users.
type
reportableEvent
struct
{
Priority
int
...
...
@@ -66,7 +64,7 @@ func (e *eventManager) ReportEvent(priority int, category, evtType,
// ReportableEvent objects. It returns the internal index
// of the callback so that it can be deleted later.
func
(
e
*
eventManager
)
RegisterEventCallback
(
name
string
,
myFunc
EventCallbackFunction
)
error
{
myFunc
interfaces
.
EventCallbackFunction
)
error
{
_
,
existsAlready
:=
e
.
eventCbs
.
LoadOrStore
(
name
,
myFunc
)
if
existsAlready
{
return
errors
.
Errorf
(
"Key %s already exists as event callback"
,
...
...
@@ -103,7 +101,7 @@ func (e *eventManager) reportEventsHandler(stop *stoppable.Single) {
// the event queue explode. The API will report errors
// in the logging any time the event queue gets full.
e
.
eventCbs
.
Range
(
func
(
name
,
myFunc
interface
{})
bool
{
f
:=
myFunc
.
(
EventCallbackFunction
)
f
:=
myFunc
.
(
interfaces
.
EventCallbackFunction
)
f
(
evt
.
Priority
,
evt
.
Category
,
evt
.
EventType
,
evt
.
Details
)
return
true
...
...
@@ -122,7 +120,7 @@ func (c *Client) ReportEvent(priority int, category, evtType, details string) {
// ReportableEvent objects. It returns the internal index
// of the callback so that it can be deleted later.
func
(
c
*
Client
)
RegisterEventCallback
(
name
string
,
myFunc
EventCallbackFunction
)
error
{
myFunc
interfaces
.
EventCallbackFunction
)
error
{
return
c
.
events
.
RegisterEventCallback
(
name
,
myFunc
)
}
...
...
This diff is collapsed.
Click to expand it.
bindings/event.go
+
2
−
2
View file @
3d5b474c
...
...
@@ -8,14 +8,14 @@
package
bindings
import
(
"gitlab.com/elixxir/client/
api
"
"gitlab.com/elixxir/client/
interfaces
"
)
// RegisterEventCallback records the given function to receive
// ReportableEvent objects. It returns the internal index
// of the callback so that it can be deleted later.
func
(
c
*
Client
)
RegisterEventCallback
(
name
string
,
myFunc
api
.
EventCallbackFunction
)
error
{
myFunc
interfaces
.
EventCallbackFunction
)
error
{
return
c
.
api
.
RegisterEventCallback
(
name
,
myFunc
)
}
...
...
This diff is collapsed.
Click to expand it.
interfaces/event.go
0 → 100644
+
11
−
0
View file @
3d5b474c
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package
interfaces
// EventCallbackFunction defines the callback functions for client event reports
type
EventCallbackFunction
func
(
priority
int
,
category
,
evtType
,
details
string
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment