Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
perso-distributed-systems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
xavier.perret
perso-distributed-systems
Commits
9bcd3e85
Commit
9bcd3e85
authored
2 years ago
by
Xavier Perret
Browse files
Options
Downloads
Patches
Plain Diff
added object storage
parent
8f3e88cb
No related branches found
No related tags found
1 merge request
!2
added file to separate client function from the server
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/server.go
+20
-4
20 additions, 4 deletions
app/server.go
with
20 additions
and
4 deletions
app/server.go
+
20
−
4
View file @
9bcd3e85
package
main
package
main
import
(
import
(
"context"
"fmt"
"fmt"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v3"
"log"
"net"
"net"
command_line
"node/command-line"
ObjectStorage
"node/object-storage"
ObjectStorage
"node/object-storage"
ProcessConnection
"node/process-connection"
ProcessConnection
"node/process-connection"
.
"node/types"
.
"node/types"
...
@@ -34,8 +37,6 @@ func listenForConnections(serverConfig Config, objectStorage Blob, addressToList
...
@@ -34,8 +37,6 @@ func listenForConnections(serverConfig Config, objectStorage Blob, addressToList
fmt
.
Println
(
"Server is ready to accept connections"
)
fmt
.
Println
(
"Server is ready to accept connections"
)
fmt
.
Println
(
"listening on "
,
completeAddress
)
fmt
.
Println
(
"listening on "
,
completeAddress
)
ServerReady
=
true
var
mu
sync
.
Mutex
var
mu
sync
.
Mutex
for
{
for
{
// Listening for connections
// Listening for connections
...
@@ -49,6 +50,7 @@ func listenForConnections(serverConfig Config, objectStorage Blob, addressToList
...
@@ -49,6 +50,7 @@ func listenForConnections(serverConfig Config, objectStorage Blob, addressToList
}
}
func
main
()
{
func
main
()
{
ctx
:=
context
.
Background
()
argsLen
:=
len
(
os
.
Args
)
argsLen
:=
len
(
os
.
Args
)
isThereEnoughArgs
:=
argsLen
<=
1
isThereEnoughArgs
:=
argsLen
<=
1
if
isThereEnoughArgs
{
if
isThereEnoughArgs
{
...
@@ -87,10 +89,24 @@ func main() {
...
@@ -87,10 +89,24 @@ func main() {
}
}
azureCreds
:=
ObjectStorage
.
InitAzureCredentials
(
"hepiadistributedsystems"
)
azureCreds
:=
ObjectStorage
.
InitAzureCredentials
(
"hepiadistributedsystems"
)
blobName
:=
"blo
ckchain"
+
"-"
+
"database"
+
"
"
+
strconv
.
Itoa
(
serverConfig
.
ID
)
blobName
:=
"blo
b-number-
"
+
strconv
.
Itoa
(
serverConfig
.
ID
)
objectStorage
:=
ObjectStorage
.
InitializeBlobFromObjectStorageCreds
(
blobName
,
azureCreds
)
objectStorage
:=
ObjectStorage
.
InitializeBlobFromObjectStorageCreds
(
blobName
,
azureCreds
)
addressToListenOn
:=
"0.0.0.0"
addressToListenOn
:=
"0.0.0.0"
go
listenForConnections
(
serverConfig
,
objectStorage
,
addressToListenOn
,
amIRoot
)
go
listenForConnections
(
serverConfig
,
objectStorage
,
addressToListenOn
,
amIRoot
)
userInputLoop
(
serverConfig
,
true
)
command_line
.
UserInputLoop
(
serverConfig
,
true
,
objectStorage
)
_
,
err
=
objectStorage
.
BlockBlobClient
.
Delete
(
ctx
,
nil
)
if
err
!=
nil
{
fmt
.
Println
(
"Error while deleting the blob"
,
err
)
fmt
.
Println
(
"This previous error is normal if the blob was already deleted or wasn't created"
)
}
// Delete the container
fmt
.
Println
(
"Deleting the container "
+
objectStorage
.
BlobName
)
_
,
err
=
objectStorage
.
ContainerClient
.
Delete
(
ctx
,
nil
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failure: %+v"
,
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