Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk Examples
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
elixxir
xxdk Examples
Commits
b79a47e5
Commit
b79a47e5
authored
Jul 7, 2022
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Imrpove experience running restlike examples
parent
cc972639
No related branches found
No related tags found
1 merge request
!3
Rest single use client
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
restSingleUseClient/main.go
+2
-1
2 additions, 1 deletion
restSingleUseClient/main.go
restSingleUseServer/endpoints.go
+5
-2
5 additions, 2 deletions
restSingleUseServer/endpoints.go
restSingleUseServer/main.go
+4
-1
4 additions, 1 deletion
restSingleUseServer/main.go
with
11 additions
and
4 deletions
restSingleUseClient/main.go
+
2
−
1
View file @
b79a47e5
...
@@ -222,11 +222,12 @@ func main() {
...
@@ -222,11 +222,12 @@ func main() {
jww
.
INFO
.
Printf
(
"Response: %+v"
,
response
)
jww
.
INFO
.
Printf
(
"Response: %+v"
,
response
)
// Keep app running to receive messages------------------------------------
-----------
// Keep app running to receive messages------------------------------------
// Wait until the user terminates the program
// Wait until the user terminates the program
c
:=
make
(
chan
os
.
Signal
)
c
:=
make
(
chan
os
.
Signal
)
signal
.
Notify
(
c
,
os
.
Interrupt
,
syscall
.
SIGTERM
)
signal
.
Notify
(
c
,
os
.
Interrupt
,
syscall
.
SIGTERM
)
jww
.
DEBUG
.
Printf
(
"Waiting for SIGTERM signal to close process"
)
<-
c
<-
c
err
=
e2eClient
.
StopNetworkFollower
()
err
=
e2eClient
.
StopNetworkFollower
()
...
...
This diff is collapsed.
Click to expand it.
restSingleUseServer/endpoints.go
+
5
−
2
View file @
b79a47e5
...
@@ -12,7 +12,10 @@ import (
...
@@ -12,7 +12,10 @@ import (
// the lower level of the restlike package returns an error
// the lower level of the restlike package returns an error
// to the requester.
// to the requester.
// User-defined message handling logic goes here.
// User-defined message handling logic goes here.
func
Callback
(
request
*
restlike
.
Message
)
(
response
*
restlike
.
Message
)
{
func
Callback
(
request
*
restlike
.
Message
)
*
restlike
.
Message
{
jww
.
INFO
.
Printf
(
"Request received: %v"
,
request
)
jww
.
INFO
.
Printf
(
"Request received: %v"
,
request
)
return
response
:=
&
restlike
.
Message
{}
response
.
Headers
=
&
restlike
.
Headers
{
Headers
:
[]
byte
(
"this is a response"
)}
response
.
Content
=
[]
byte
(
"This is content"
)
return
response
}
}
This diff is collapsed.
Click to expand it.
restSingleUseServer/main.go
+
4
−
1
View file @
b79a47e5
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
func
main
()
{
func
main
()
{
// Logging
// Logging
initLog
(
1
,
"
client
.log"
)
initLog
(
1
,
"
server
.log"
)
// Create a new client object----------------------------------------------
// Create a new client object----------------------------------------------
// NOTE: For some (or all) of these parameters, you may want to use a
// NOTE: For some (or all) of these parameters, you may want to use a
...
@@ -127,6 +127,7 @@ func main() {
...
@@ -127,6 +127,7 @@ func main() {
// Initialize the server
// Initialize the server
restlikeServer
:=
single
.
NewServer
(
identity
.
ID
,
dhKeyPrivateKey
,
restlikeServer
:=
single
.
NewServer
(
identity
.
ID
,
dhKeyPrivateKey
,
grp
,
e2eClient
.
GetCmix
())
grp
,
e2eClient
.
GetCmix
())
jww
.
INFO
.
Printf
(
"Initialized restlike single use server"
)
// Implement restlike endpoint---------------------------------------------
// Implement restlike endpoint---------------------------------------------
...
@@ -135,6 +136,7 @@ func main() {
...
@@ -135,6 +136,7 @@ func main() {
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to add endpoint to server: %v"
,
err
)
jww
.
FATAL
.
Panicf
(
"Failed to add endpoint to server: %v"
,
err
)
}
}
jww
.
DEBUG
.
Printf
(
"Added endpoint for restlike single use server"
)
// Start network threads---------------------------------------------------
// Start network threads---------------------------------------------------
...
@@ -178,6 +180,7 @@ func main() {
...
@@ -178,6 +180,7 @@ func main() {
// Wait until the user terminates the program
// Wait until the user terminates the program
c
:=
make
(
chan
os
.
Signal
)
c
:=
make
(
chan
os
.
Signal
)
signal
.
Notify
(
c
,
os
.
Interrupt
,
syscall
.
SIGTERM
)
signal
.
Notify
(
c
,
os
.
Interrupt
,
syscall
.
SIGTERM
)
jww
.
DEBUG
.
Printf
(
"Waiting for SIGTERM signal to close process"
)
<-
c
<-
c
err
=
e2eClient
.
StopNetworkFollower
()
err
=
e2eClient
.
StopNetworkFollower
()
...
...
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