mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-27 13:48:49 +08:00
NOISSUE - Update event fields naming (#713)
* Update event fields naming Replace `id` with `thing_id`. Fix typo in `success` field. Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> * Update docs Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
This commit is contained in:
parent
de736a5c47
commit
fe9f4dca8e
@ -51,7 +51,7 @@ type createConfigEvent struct {
|
||||
|
||||
func (cce createConfigEvent) encode() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"id": cce.mfThing,
|
||||
"thing_id": cce.mfThing,
|
||||
"owner": cce.owner,
|
||||
"name": cce.name,
|
||||
"channels": strings.Join(cce.mfChannels, ", "),
|
||||
@ -71,7 +71,7 @@ type updateConfigEvent struct {
|
||||
|
||||
func (uce updateConfigEvent) encode() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"id": uce.mfThing,
|
||||
"thing_id": uce.mfThing,
|
||||
"name": uce.name,
|
||||
"content": uce.content,
|
||||
"timestamp": uce.timestamp.Unix(),
|
||||
@ -86,22 +86,22 @@ type removeConfigEvent struct {
|
||||
|
||||
func (rce removeConfigEvent) encode() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"id": rce.mfThing,
|
||||
"thing_id": rce.mfThing,
|
||||
"timestamp": rce.timestamp.Unix(),
|
||||
"operation": configRemove,
|
||||
}
|
||||
}
|
||||
|
||||
type bootstrapEvent struct {
|
||||
externalID string
|
||||
successfull bool
|
||||
timestamp time.Time
|
||||
externalID string
|
||||
success bool
|
||||
timestamp time.Time
|
||||
}
|
||||
|
||||
func (be bootstrapEvent) encode() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"external_id": be.externalID,
|
||||
"successfull": be.successfull,
|
||||
"success": be.success,
|
||||
"timestamp": be.timestamp.Unix(),
|
||||
"operation": thingBootstrap,
|
||||
}
|
||||
@ -115,7 +115,7 @@ type changeStateEvent struct {
|
||||
|
||||
func (cse changeStateEvent) encode() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"id": cse.mfThing,
|
||||
"thing_id": cse.mfThing,
|
||||
"state": cse.state.String(),
|
||||
"timestamp": cse.timestamp.Unix(),
|
||||
"operation": thingStateChange,
|
||||
@ -130,7 +130,7 @@ type updateConnectionsEvent struct {
|
||||
|
||||
func (uce updateConnectionsEvent) encode() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"id": uce.mfThing,
|
||||
"thing_id": uce.mfThing,
|
||||
"channels": strings.Join(uce.mfChannels, ", "),
|
||||
"timestamp": uce.timestamp.Unix(),
|
||||
"operation": thingUpdateConnections,
|
||||
|
@ -121,13 +121,13 @@ func (es eventStore) Bootstrap(externalKey, externalID string) (bootstrap.Config
|
||||
cfg, err := es.svc.Bootstrap(externalKey, externalID)
|
||||
|
||||
ev := bootstrapEvent{
|
||||
externalID: externalID,
|
||||
timestamp: time.Now(),
|
||||
successfull: true,
|
||||
externalID: externalID,
|
||||
timestamp: time.Now(),
|
||||
success: true,
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
ev.successfull = false
|
||||
ev.success = false
|
||||
}
|
||||
|
||||
es.add(ev)
|
||||
|
@ -119,7 +119,7 @@ func TestAdd(t *testing.T) {
|
||||
key: validToken,
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
"id": "1",
|
||||
"thing_id": "1",
|
||||
"owner": email,
|
||||
"name": config.Name,
|
||||
"channels": strings.Join(channels, ", "),
|
||||
@ -214,7 +214,7 @@ func TestUpdate(t *testing.T) {
|
||||
key: validToken,
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
"id": modified.MFThing,
|
||||
"thing_id": modified.MFThing,
|
||||
"name": modified.Name,
|
||||
"content": modified.Content,
|
||||
"timestamp": strconv.FormatInt(time.Now().Unix(), 10),
|
||||
@ -279,7 +279,7 @@ func TestUpdateConnections(t *testing.T) {
|
||||
connections: []string{"2"},
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
"id": saved.MFThing,
|
||||
"thing_id": saved.MFThing,
|
||||
"channels": "2",
|
||||
"timestamp": strconv.FormatInt(time.Now().Unix(), 10),
|
||||
"operation": thingUpdateConnections,
|
||||
@ -362,7 +362,7 @@ func TestRemove(t *testing.T) {
|
||||
key: validToken,
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
"id": saved.MFThing,
|
||||
"thing_id": saved.MFThing,
|
||||
"timestamp": strconv.FormatInt(time.Now().Unix(), 10),
|
||||
"operation": configRemove,
|
||||
},
|
||||
@ -426,7 +426,7 @@ func TestBootstrap(t *testing.T) {
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
"external_id": saved.ExternalID,
|
||||
"successfull": "1",
|
||||
"success": "1",
|
||||
"timestamp": strconv.FormatInt(time.Now().Unix(), 10),
|
||||
"operation": thingBootstrap,
|
||||
},
|
||||
@ -438,7 +438,7 @@ func TestBootstrap(t *testing.T) {
|
||||
err: bootstrap.ErrNotFound,
|
||||
event: map[string]interface{}{
|
||||
"external_id": saved.ExternalID,
|
||||
"successfull": "0",
|
||||
"success": "0",
|
||||
"timestamp": strconv.FormatInt(time.Now().Unix(), 10),
|
||||
"operation": thingBootstrap,
|
||||
},
|
||||
@ -496,7 +496,7 @@ func TestChangeState(t *testing.T) {
|
||||
state: bootstrap.Active,
|
||||
err: nil,
|
||||
event: map[string]interface{}{
|
||||
"id": saved.MFThing,
|
||||
"thing_id": saved.MFThing,
|
||||
"state": bootstrap.Active.String(),
|
||||
"timestamp": strconv.FormatInt(time.Now().Unix(), 10),
|
||||
"operation": thingStateChange,
|
||||
|
@ -442,7 +442,7 @@ new `create` event. This event will have the following format:
|
||||
12) "1555404899"
|
||||
13) "operation"
|
||||
14) "config.create"
|
||||
15) "id"
|
||||
15) "thing_id"
|
||||
16) "63a110d4-2b77-48d2-aa46-2582681eeb82"
|
||||
```
|
||||
|
||||
@ -457,7 +457,7 @@ new `update` event. This event will have the following format:
|
||||
4) "1555405104"
|
||||
5) "operation"
|
||||
6) "config.update"
|
||||
7) "id"
|
||||
7) "thing_id"
|
||||
8) "63a110d4-2b77-48d2-aa46-2582681eeb82"
|
||||
9) "name"
|
||||
10) "weio"
|
||||
@ -468,7 +468,7 @@ Whenever configuration is removed, `bootstrap` service will generate and publish
|
||||
new `remove` event. This event will have the following format:
|
||||
```
|
||||
1) "1555405464328-0"
|
||||
2) 1) "id"
|
||||
2) 1) "thing_id"
|
||||
2) "63a110d4-2b77-48d2-aa46-2582681eeb82"
|
||||
3) "timestamp"
|
||||
4) "1555405464"
|
||||
@ -483,7 +483,7 @@ new `bootstrap` event. This event will have the following format:
|
||||
1) "1555405173785-0"
|
||||
2) 1) "externalID"
|
||||
2) "9c:b6:d:eb:9f:fd"
|
||||
3) "successful"
|
||||
3) "success"
|
||||
4) "1"
|
||||
5) "timestamp"
|
||||
6) "1555405173"
|
||||
@ -496,7 +496,7 @@ Whenever thing's state changes, `bootstrap` service will generate and publish
|
||||
new `change state` event. This event will have the following format:
|
||||
```
|
||||
1) "1555405294806-0"
|
||||
2) 1) "id"
|
||||
2) 1) "thing_id"
|
||||
2) "63a110d4-2b77-48d2-aa46-2582681eeb82"
|
||||
3) "state"
|
||||
4) "0"
|
||||
@ -513,7 +513,7 @@ and publish new `update connections` event. This event will have the following f
|
||||
1) "1555405373360-0"
|
||||
2) 1) "operation"
|
||||
2) "thing.update_connections"
|
||||
3) "id"
|
||||
3) "thing_id"
|
||||
4) "63a110d4-2b77-48d2-aa46-2582681eeb82"
|
||||
5) "channels"
|
||||
6) "ff13ca9c-7322-4c28-a25c-4fe5c7b753fc, 925461e6-edfb-4755-9242-8a57199b90a5, c3642289-501d-4974-82f2-ecccc71b2d82"
|
||||
@ -562,4 +562,4 @@ Example of disconnect event:
|
||||
6) "disconnect"
|
||||
7) "instance"
|
||||
8) "mqtt-adapter-1"
|
||||
```
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user