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
d9d2c9dc
Commit
d9d2c9dc
authored
3 years ago
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Properly thread params for single, restlikesingle and filetransfer
parent
ef8e90f4
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!510
Release
,
!228
New bindings for api2.0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bindings/fileTransfer.go
+21
-5
21 additions, 5 deletions
bindings/fileTransfer.go
bindings/restlikeSingle.go
+7
-10
7 additions, 10 deletions
bindings/restlikeSingle.go
bindings/single.go
+2
-3
2 additions, 3 deletions
bindings/single.go
with
30 additions
and
18 deletions
bindings/fileTransfer.go
+
21
−
5
View file @
d9d2c9dc
...
...
@@ -86,9 +86,8 @@ type FileTransferReceiveProgressCallback interface {
/* Main functions */
// InitFileTransfer creates a bindings-level File Transfer manager
// Accepts client ID, ReceiveFileCallback and a ReporterFunc
func
InitFileTransfer
(
e2eID
int
)
(
*
FileTransfer
,
error
)
{
paramsJSON
:=
GetDefaultFileTransferParams
()
// Accepts e2e client ID and marshalled params JSON
func
InitFileTransfer
(
e2eID
int
,
paramsJSON
[]
byte
)
(
*
FileTransfer
,
error
)
{
// Get bindings client from singleton
e2eCl
,
err
:=
e2eTrackerSingleton
.
get
(
e2eID
)
...
...
@@ -120,9 +119,15 @@ func InitFileTransfer(e2eID int) (*FileTransfer, error) {
}
// Send is the bindings-level function for sending a File
func
(
f
*
FileTransfer
)
Send
(
payload
,
recipientID
[]
byte
,
retry
float32
,
// Accepts:
// FileSend JSON payload
// Marshalled recipient ID
// Marshalled e2e Params JSON
// Number of retries allowed
// Limit on duration between retries
// FileTransferSentProgressCallback interface
func
(
f
*
FileTransfer
)
Send
(
payload
,
recipientID
,
paramsJSON
[]
byte
,
retry
float32
,
period
string
,
callback
FileTransferSentProgressCallback
)
([]
byte
,
error
)
{
paramsJSON
:=
GetDefaultE2EParams
()
// Unmarshal recipient ID
recipient
,
err
:=
id
.
Unmarshal
(
recipientID
)
if
err
!=
nil
{
...
...
@@ -196,6 +201,12 @@ func (f *FileTransfer) CloseSend(tidBytes []byte) error {
/* Callback registration functions */
// RegisterSentProgressCallback allows for the registration of a callback to
// track the progress of an individual sent file transfer.
// SentProgressCallback is auto registered on Send; this function should be
// called when resuming clients or registering extra callbacks.
// Accepts ID of the transfer, callback for transfer progress,
// and period between retries
func
(
f
*
FileTransfer
)
RegisterSentProgressCallback
(
tidBytes
[]
byte
,
callback
FileTransferSentProgressCallback
,
period
string
)
error
{
cb
:=
func
(
completed
bool
,
arrived
,
total
uint16
,
...
...
@@ -218,6 +229,11 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
return
f
.
ft
.
RegisterSentProgressCallback
(
&
tid
,
cb
,
p
)
}
// RegisterReceivedProgressCallback allows for the registration of a
// callback to track the progress of an individual received file transfer.
// This should be done when a new transfer is received on the
// ReceiveCallback.
// Accepts ID of the transfer, callback for transfer progress and period between retries
func
(
f
*
FileTransfer
)
RegisterReceivedProgressCallback
(
tidBytes
[]
byte
,
callback
FileTransferReceiveProgressCallback
,
period
string
)
error
{
cb
:=
func
(
completed
bool
,
received
,
total
uint16
,
rt
fileTransfer
.
ReceivedTransfer
,
t
fileTransfer
.
FilePartTracker
,
err
error
)
{
...
...
This diff is collapsed.
Click to expand it.
bindings/restlikeSingle.go
+
7
−
10
View file @
d9d2c9dc
...
...
@@ -13,14 +13,10 @@ type RestlikeCallback interface {
Callback
([]
byte
,
error
)
}
type
RequestParams
struct
{
}
// RequestRestLike sends a restlike request to a given contact
// Accepts marshalled contact object as recipient,
byte slice payload & headers, method enum and a URI
// Accepts marshalled contact object as recipient,
marshalled RestlikeMessage and params JSON
// Returns json marshalled restlike.Message & error
func
RequestRestLike
(
e2eID
int
,
recipient
,
request
[]
byte
)
([]
byte
,
error
)
{
paramsJSON
:=
GetDefaultSingleUseParams
()
func
RequestRestLike
(
e2eID
int
,
recipient
,
request
,
paramsJSON
[]
byte
)
([]
byte
,
error
)
{
c
,
err
:=
e2eTrackerSingleton
.
get
(
e2eID
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -56,10 +52,11 @@ func RequestRestLike(e2eID int, recipient, request []byte) ([]byte, error) {
}
// AsyncRequestRestLike sends an asynchronous restlike request to a given contact
// Accepts marshalled contact object as recipient, byte slice payload & headers, method enum, URI, and a RestlikeCallback
// Returns an error, and the RestlikeCallback will be called with the results of json marshalling the response when received
func
AsyncRequestRestLike
(
e2eID
int
,
recipient
,
request
[]
byte
,
cb
RestlikeCallback
)
error
{
paramsJSON
:=
GetDefaultSingleUseParams
()
// Accepts e2e client ID, marshalled contact object as recipient,
// marshalled RestlikeMessage, marshalled Params json, and a RestlikeCallback
// Returns an error, and the RestlikeCallback will be called with the results
// of json marshalling the response when received
func
AsyncRequestRestLike
(
e2eID
int
,
recipient
,
request
,
paramsJSON
[]
byte
,
cb
RestlikeCallback
)
error
{
c
,
err
:=
e2eTrackerSingleton
.
get
(
e2eID
)
if
err
!=
nil
{
return
err
...
...
This diff is collapsed.
Click to expand it.
bindings/single.go
+
2
−
3
View file @
d9d2c9dc
...
...
@@ -11,10 +11,9 @@ import (
/* PUBLIC WRAPPER METHODS */
// TransmitSingleUse accepts a marshalled recipient contact object, tag, payload, SingleUseResponse callback func & a
// TransmitSingleUse accepts a marshalled recipient contact object, tag, payload,
params JSON,
SingleUseResponse callback func & a
// Client. Transmits payload to recipient via single use
func
TransmitSingleUse
(
e2eID
int
,
recipient
[]
byte
,
tag
string
,
payload
[]
byte
,
responseCB
SingleUseResponse
)
([]
byte
,
error
)
{
paramsJSON
:=
GetDefaultSingleUseParams
()
func
TransmitSingleUse
(
e2eID
int
,
recipient
[]
byte
,
tag
string
,
payload
,
paramsJSON
[]
byte
,
responseCB
SingleUseResponse
)
([]
byte
,
error
)
{
e2eCl
,
err
:=
e2eTrackerSingleton
.
get
(
e2eID
)
if
err
!=
nil
{
return
nil
,
err
...
...
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