Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix instructions under example #199

Merged
merged 3 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions deviceshifu/pkg/deviceshifu/deviceshifu.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ func (handler DeviceCommandHandlerHTTP) commandHandleFunc() http.HandlerFunc {
log.Printf("timeout URI parsing error" + parseErr.Error())
return
}

r.URL.Query().Del(deviceshifubase.DEVICE_INSTRUCTION_TIMEOUT_URI_QUERY_STR)
}

switch reqType {
Expand Down
5 changes: 3 additions & 2 deletions deviceshifu/pkg/deviceshifubase/deviceshifubase.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (
KUBERNETES_CONFIG_DEFAULT string = ""
DEVICE_INSTRUCTION_TIMEOUT_URI_QUERY_STR string = "timeout"
DEVICE_DEFAULT_GLOBAL_TIMEOUT_SECONDS int = 3
DEFAULT_HTTP_SERVER_TIMEOUT_SECONDS int = 0
)

var (
Expand Down Expand Up @@ -105,8 +106,8 @@ func New(deviceShifuMetadata *DeviceShifuMetaData) (*DeviceShifuBase, *http.Serv
Server: &http.Server{
Addr: DEVICE_DEFAULT_PORT_STR,
Handler: mux,
ReadTimeout: 60 * time.Second,
WriteTimeout: 60 * time.Second,
ReadTimeout: time.Duration(DEFAULT_HTTP_SERVER_TIMEOUT_SECONDS) * time.Second,
WriteTimeout: time.Duration(DEFAULT_HTTP_SERVER_TIMEOUT_SECONDS) * time.Second,
},
DeviceShifuConfig: deviceShifuConfig,
EdgeDevice: edgeDevice,
Expand Down
2 changes: 0 additions & 2 deletions deviceshifu/pkg/deviceshifubase/deviceshifubase_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"log"
"time"

"edgenesis.io/shifu/k8s/crd/api/v1alpha1"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -164,7 +163,6 @@ func NewEdgeDeviceRestClient(config *rest.Config) (*rest.RESTClient, error) {
crdConfig.APIPath = "/apis"
crdConfig.NegotiatedSerializer = serializer.NewCodecFactory(scheme.Scheme)
crdConfig.UserAgent = rest.DefaultKubernetesUserAgent()
crdConfig.Timeout = 3 * time.Second
exampleRestClient, err := rest.UnversionedRESTClientFor(crdConfig)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ data:
driverImage: http-device:v0.0.1
# available instructions
instructions: |
status:
info:
instructions:
status:
info:
# telemetry retrieval methods
# in this example, a device_health telemetry is collected by calling hello instruction every 1 second
telemetries: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data:
instructions: |

telemetries: |
device_health:
properties:
telemetries:
device_health:
properties:

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ data:
driverSku: Test OPC UA Server
driverImage:
instructions: |
get_value:
instructionProperties:
OPCUANodeID: "ns=2;i=2"
get_time:
instructionProperties:
OPCUANodeID: "i=2258"
get_server:
instructionProperties:
OPCUANodeID: "i=2261"
instructions:
get_value:
instructionProperties:
OPCUANodeID: "ns=2;i=2"
get_time:
instructionProperties:
OPCUANodeID: "i=2258"
get_server:
instructionProperties:
OPCUANodeID: "i=2261"
telemetries: |
telemetrySettings:
telemetryUpdateIntervalInMiliseconds: 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ data:
driverSku: HikVision
driverImage: edgenesis/camera-python:v0.0.1
instructions: |
capture:
info:
stream:
move/up:
move/down:
move/left:
move/right:
instructions:
capture:
info:
stream:
move/up:
move/down:
move/left:
move/right:
# Telemetries are configurable health checks of the EdgeDevice
# Developer/user can configure certain instructions to be used as health check
# of the device. In this example, the device_health telemetry is mapped to
# "get_status" instruction, executed every 1000 ms
telemetries: |
device_health:
properties:
instruction: info
initialDelayMs: 1000
intervalMs: 1000
telemetries:
device_health:
properties:
instruction: info
initialDelayMs: 1000
intervalMs: 1000

Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ data:
driverExecution: " "
# available instructions
instructions: |
sendsinglebit:
sendcontent:
getcontent:
getcpuordercode:
instructions:
sendsinglebit:
sendcontent:
getcontent:
getcpuordercode:
# telemetry retrieval methods
# in this example, a device_health telemetry is collected by calling hello instruction every 1 second
telemetries: |
device_health:
properties:
instruction: getcpuordercode
initialDelayMs: 1000
intervalMs: 1000
telemetries:
device_health:
properties:
instruction: getcpuordercode
initialDelayMs: 1000
intervalMs: 1000