Upgrading vendor folder dependencies.
This commit is contained in:
parent
4a0cbcd770
commit
acbe9ad9e5
229 changed files with 10735 additions and 4528 deletions
36
vendor/git.apache.org/thrift.git/tutorial/cl/Makefile.am
generated
vendored
36
vendor/git.apache.org/thrift.git/tutorial/cl/Makefile.am
generated
vendored
|
@ -15,19 +15,30 @@
|
|||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
setup-local-lisp-env: ensure-externals.sh
|
||||
bash ensure-externals.sh
|
||||
|
||||
gen-cl: $(top_srcdir)/tutorial/tutorial.thrift
|
||||
$(THRIFT) --gen cl -r $<
|
||||
|
||||
TutorialServer: make-tutorial-server.lisp
|
||||
ALL_FILE_PREREQS = \
|
||||
load-locally.lisp \
|
||||
make-tutorial-server.lisp \
|
||||
make-tutorial-client.lisp \
|
||||
shared-implementation.lisp \
|
||||
thrift-tutorial.asd \
|
||||
tutorial-implementation.lisp
|
||||
|
||||
# NOTE: the server and client cannot be built in parallel
|
||||
# because on loading the make-tutorial-* scripts SBCL will
|
||||
# attempt to compile their dependencies. Unfortunately,
|
||||
# because their dependencies are shared, parallel jobs can
|
||||
# end up overwriting or corrupting the compiled files
|
||||
all-local: gen-cl setup-local-lisp-env $(ALL_FILE_PREREQS)
|
||||
$(SBCL) --script make-tutorial-server.lisp
|
||||
|
||||
TutorialClient: make-tutorial-client.lisp
|
||||
$(SBCL) --script make-tutorial-client.lisp
|
||||
|
||||
all-local: gen-cl TutorialClient TutorialServer
|
||||
|
||||
tutorialserver: all
|
||||
./TutorialServer
|
||||
|
||||
|
@ -35,9 +46,16 @@ tutorialclient: all
|
|||
./TutorialClient
|
||||
|
||||
clean-local:
|
||||
$(RM) -r gen-*
|
||||
$(RM) TutorialServer
|
||||
$(RM) TutorialClient
|
||||
-$(RM) -r gen-*
|
||||
-$(RM) -r externals
|
||||
-$(RM) -r quicklisp
|
||||
-$(RM) -r lib
|
||||
-$(RM) quicklisp.lisp
|
||||
-$(RM) backport-update.zip
|
||||
-$(RM) shared-implementation.fasl
|
||||
-$(RM) tutorial-implementation.fasl
|
||||
-$(RM) TutorialServer
|
||||
-$(RM) TutorialClient
|
||||
|
||||
EXTRA_DIST = \
|
||||
tutorial-implementation.lisp \
|
||||
|
|
1
vendor/git.apache.org/thrift.git/tutorial/cl/ensure-externals.sh
generated
vendored
Symbolic link
1
vendor/git.apache.org/thrift.git/tutorial/cl/ensure-externals.sh
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../lib/cl/ensure-externals.sh
|
22
vendor/git.apache.org/thrift.git/tutorial/cl/load-locally.lisp
generated
vendored
Normal file
22
vendor/git.apache.org/thrift.git/tutorial/cl/load-locally.lisp
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
(in-package #:cl-user)
|
||||
|
||||
;;;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||
;;;; you may not use this file except in compliance with the License.
|
||||
;;;; You may obtain a copy of the License at
|
||||
;;;;
|
||||
;;;; http://www.apache.org/licenses/LICENSE-2.0
|
||||
;;;;
|
||||
;;;; Unless required by applicable law or agreed to in writing, software
|
||||
;;;; distributed under the License is distributed on an "AS IS" BASIS,
|
||||
;;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
;;;; See the License for the specific language governing permissions and
|
||||
;;;; limitations under the License.
|
||||
|
||||
;;;; Just a script for loading the library itself, using bundled dependencies.
|
||||
;;;; This is an identical copy of the file in lib/cl.
|
||||
|
||||
(require "asdf")
|
||||
|
||||
(load (merge-pathnames "externals/bundle.lisp" *load-truename*))
|
||||
(asdf:load-asd (merge-pathnames "lib/de.setf.thrift-backport-update/thrift.asd" *load-truename*))
|
||||
(asdf:load-system :thrift)
|
2
vendor/git.apache.org/thrift.git/tutorial/cl/make-tutorial-client.lisp
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/cl/make-tutorial-client.lisp
generated
vendored
|
@ -13,7 +13,7 @@
|
|||
;;;; limitations under the License.
|
||||
|
||||
(require "asdf")
|
||||
(load (merge-pathnames "../../lib/cl/load-locally.lisp" *load-truename*))
|
||||
(load (merge-pathnames "load-locally.lisp" *load-truename*))
|
||||
(asdf:load-system :net.didierverna.clon)
|
||||
(asdf:load-asd (merge-pathnames "gen-cl/shared/thrift-gen-shared.asd" *load-truename*))
|
||||
(asdf:load-asd (merge-pathnames "gen-cl/tutorial/thrift-gen-tutorial.asd" *load-truename*))
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/cl/make-tutorial-server.lisp
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/cl/make-tutorial-server.lisp
generated
vendored
|
@ -13,7 +13,7 @@
|
|||
;;;; limitations under the License.
|
||||
|
||||
(require "asdf")
|
||||
(load (merge-pathnames "../../lib/cl/load-locally.lisp" *load-truename*))
|
||||
(load (merge-pathnames "load-locally.lisp" *load-truename*))
|
||||
(asdf:load-system :net.didierverna.clon)
|
||||
(asdf:load-asd (merge-pathnames "gen-cl/shared/thrift-gen-shared.asd" *load-truename*))
|
||||
(asdf:load-asd (merge-pathnames "gen-cl/tutorial/thrift-gen-tutorial.asd" *load-truename*))
|
||||
|
|
|
@ -51,5 +51,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("0.12.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.0")]
|
||||
|
|
|
@ -51,5 +51,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("0.12.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.12.0.0")]
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/dart/client/pubspec.yaml
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/dart/client/pubspec.yaml
generated
vendored
|
@ -16,7 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
name: tutorial_client
|
||||
version: 1.0.0-dev
|
||||
version: 0.12.0
|
||||
description: A Dart client implementation of the Apache Thrift tutorial
|
||||
author: Apache Thrift Developers <dev@thrift.apache.org>
|
||||
homepage: http://thrift.apache.org
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/dart/console_client/pubspec.yaml
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/dart/console_client/pubspec.yaml
generated
vendored
|
@ -16,7 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
name: tutorial_console_client
|
||||
version: 1.0.0-dev
|
||||
version: 0.12.0
|
||||
description: >
|
||||
A Dart console client to implementation of the Apache Thrift tutorial
|
||||
author: Apache Thrift Developers <dev@thrift.apache.org>
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/dart/server/pubspec.yaml
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/dart/server/pubspec.yaml
generated
vendored
|
@ -16,7 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
name: tutorial_server
|
||||
version: 1.0.0-dev
|
||||
version: 0.12.0
|
||||
description: A Dart server to support the Apache Thrift tutorial
|
||||
author: Apache Thrift Developers <dev@thrift.apache.org>
|
||||
homepage: http://thrift.apache.org
|
||||
|
|
6
vendor/git.apache.org/thrift.git/tutorial/delphi/DelphiClient/DelphiClient.dproj
generated
vendored
6
vendor/git.apache.org/thrift.git/tutorial/delphi/DelphiClient/DelphiClient.dproj
generated
vendored
|
@ -82,8 +82,8 @@
|
|||
<VersionInfo>
|
||||
<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
|
||||
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">1</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">0</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">0</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">12</VersionInfo>
|
||||
<VersionInfo Name="Release">0</VersionInfo>
|
||||
<VersionInfo Name="Build">0</VersionInfo>
|
||||
<VersionInfo Name="Debug">False</VersionInfo>
|
||||
|
@ -97,7 +97,7 @@
|
|||
<VersionInfoKeys>
|
||||
<VersionInfoKeys Name="CompanyName"/>
|
||||
<VersionInfoKeys Name="FileDescription">Thrift Tutorial</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="FileVersion">0.12.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="InternalName">DelphiClient</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="LegalCopyright">Copyright © 2012 The Apache Software Foundation</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="LegalTrademarks"/>
|
||||
|
|
6
vendor/git.apache.org/thrift.git/tutorial/delphi/DelphiServer/DelphiServer.dproj
generated
vendored
6
vendor/git.apache.org/thrift.git/tutorial/delphi/DelphiServer/DelphiServer.dproj
generated
vendored
|
@ -81,8 +81,8 @@
|
|||
<VersionInfo>
|
||||
<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
|
||||
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">1</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">0</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">0</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">12</VersionInfo>
|
||||
<VersionInfo Name="Release">0</VersionInfo>
|
||||
<VersionInfo Name="Build">0</VersionInfo>
|
||||
<VersionInfo Name="Debug">False</VersionInfo>
|
||||
|
@ -96,7 +96,7 @@
|
|||
<VersionInfoKeys>
|
||||
<VersionInfoKeys Name="CompanyName"/>
|
||||
<VersionInfoKeys Name="FileDescription">Thrift Tutorial</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="FileVersion">0.12.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="InternalName">DelphiServer</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="LegalCopyright">Copyright © 2012 The Apache Software Foundation</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="LegalTrademarks"/>
|
||||
|
|
8
vendor/git.apache.org/thrift.git/tutorial/go/Makefile.am
generated
vendored
8
vendor/git.apache.org/thrift.git/tutorial/go/Makefile.am
generated
vendored
|
@ -22,15 +22,15 @@ gen-go/tutorial/calculator.go gen-go/shared/shared_service.go: $(top_srcdir)/tut
|
|||
|
||||
all-local: gen-go/tutorial/calculator.go
|
||||
|
||||
check: src/git.apache.org/thrift.git/lib/go/thrift thirdparty-dep
|
||||
check: src/github.com/apache/thrift/lib/go/thrift thirdparty-dep
|
||||
$(THRIFT) -r --gen go$(COMPILER_EXTRAFLAG) $(top_srcdir)/tutorial/tutorial.thrift
|
||||
cp -r gen-go/* src/
|
||||
GOPATH=`pwd` $(GO) build -o go-tutorial ./src
|
||||
GOPATH=`pwd` $(GO) build -o calculator-remote src/tutorial/calculator-remote/calculator-remote.go
|
||||
|
||||
src/git.apache.org/thrift.git/lib/go/thrift:
|
||||
mkdir -p src/git.apache.org/thrift.git/lib/go
|
||||
ln -sf $(realpath $(top_srcdir)/lib/go/thrift) src/git.apache.org/thrift.git/lib/go/thrift
|
||||
src/github.com/apache/thrift/lib/go/thrift:
|
||||
mkdir -p src/github.com/apache/thrift/lib/go
|
||||
ln -sf $(realpath $(top_srcdir)/lib/go/thrift) src/github.com/apache/thrift/lib/go/thrift
|
||||
|
||||
thirdparty-dep:
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/go/src/client.go
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/go/src/client.go
generated
vendored
|
@ -25,7 +25,7 @@ import (
|
|||
"fmt"
|
||||
"tutorial"
|
||||
|
||||
"git.apache.org/thrift.git/lib/go/thrift"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
)
|
||||
|
||||
var defaultCtx = context.Background()
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/go/src/main.go
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/go/src/main.go
generated
vendored
|
@ -22,7 +22,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"git.apache.org/thrift.git/lib/go/thrift"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/go/src/server.go
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/go/src/server.go
generated
vendored
|
@ -22,7 +22,7 @@ package main
|
|||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"git.apache.org/thrift.git/lib/go/thrift"
|
||||
"github.com/apache/thrift/lib/go/thrift"
|
||||
"tutorial"
|
||||
)
|
||||
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/hs/ThriftTutorial.cabal
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/hs/ThriftTutorial.cabal
generated
vendored
|
@ -18,7 +18,7 @@
|
|||
--
|
||||
|
||||
Name: ThriftTutorial
|
||||
Version: 0.1.0
|
||||
Version: 0.12.0
|
||||
Cabal-Version: >= 1.4
|
||||
License: OtherLicense
|
||||
Category: Foreign
|
||||
|
|
2
vendor/git.apache.org/thrift.git/tutorial/ocaml/_oasis
generated
vendored
2
vendor/git.apache.org/thrift.git/tutorial/ocaml/_oasis
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
Name: tutorial
|
||||
Version: 1.0
|
||||
Version: 0.12.0
|
||||
OASISFormat: 0.3
|
||||
Synopsis: OCaml Tutorial example
|
||||
Authors: Apache Thrift Developers <dev@thrift.apache.org>
|
||||
|
|
12
vendor/git.apache.org/thrift.git/tutorial/perl/PerlClient.pl
generated
vendored
12
vendor/git.apache.org/thrift.git/tutorial/perl/PerlClient.pl
generated
vendored
|
@ -37,10 +37,10 @@ use tutorial::Types;
|
|||
|
||||
use Data::Dumper;
|
||||
|
||||
my $socket = new Thrift::Socket('localhost',9090);
|
||||
my $transport = new Thrift::BufferedTransport($socket,1024,1024);
|
||||
my $protocol = new Thrift::BinaryProtocol($transport);
|
||||
my $client = new tutorial::CalculatorClient($protocol);
|
||||
my $socket = Thrift::Socket->new('localhost',9090);
|
||||
my $transport = Thrift::BufferedTransport->new($socket,1024,1024);
|
||||
my $protocol = Thrift::BinaryProtocol->new($transport);
|
||||
my $client = tutorial::CalculatorClient->new($protocol);
|
||||
|
||||
|
||||
eval{
|
||||
|
@ -53,7 +53,7 @@ eval{
|
|||
my $sum = $client->add(1,1);
|
||||
print "1+1=$sum\n";
|
||||
|
||||
my $work = new tutorial::Work();
|
||||
my $work = tutorial::Work->new();
|
||||
|
||||
$work->op(tutorial::Operation::DIVIDE);
|
||||
$work->num1(1);
|
||||
|
@ -63,7 +63,7 @@ eval{
|
|||
$client->calculate(1, $work);
|
||||
print "Whoa! We can divide by zero?\n";
|
||||
}; if($@) {
|
||||
warn "InvalidOperation: ".Dumper($@);
|
||||
warn 'InvalidOperation: '.Dumper($@);
|
||||
}
|
||||
|
||||
$work->op(tutorial::Operation::SUBTRACT);
|
||||
|
|
16
vendor/git.apache.org/thrift.git/tutorial/perl/PerlServer.pl
generated
vendored
16
vendor/git.apache.org/thrift.git/tutorial/perl/PerlServer.pl
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/perl
|
||||
#!/usr/bin/env perl
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -67,20 +67,20 @@ sub calculate
|
|||
} elsif ($op == tutorial::Operation::DIVIDE) {
|
||||
if ($num2 == 0)
|
||||
{
|
||||
my $x = new tutorial::InvalidOperation;
|
||||
my $x = tutorial::InvalidOperation->new();
|
||||
$x->whatOp($op);
|
||||
$x->why('Cannot divide by 0');
|
||||
die $x;
|
||||
}
|
||||
$val = $num1 / $num2;
|
||||
} else {
|
||||
my $x = new tutorial::InvalidOperation;
|
||||
my $x = tutorial::InvalidOperation->new();
|
||||
$x->whatOp($op);
|
||||
$x->why('Invalid operation');
|
||||
die $x;
|
||||
}
|
||||
|
||||
my $log = new shared::SharedStruct;
|
||||
my $log = shared::SharedStruct->new();
|
||||
$log->key($logid);
|
||||
$log->value(int($val));
|
||||
$self->{log}->{$logid} = $log;
|
||||
|
@ -104,10 +104,10 @@ sub zip
|
|||
|
||||
|
||||
eval {
|
||||
my $handler = new CalculatorHandler;
|
||||
my $processor = new tutorial::CalculatorProcessor($handler);
|
||||
my $serversocket = new Thrift::ServerSocket(9090);
|
||||
my $forkingserver = new Thrift::ForkingServer($processor, $serversocket);
|
||||
my $handler = CalculatorHandler->new();
|
||||
my $processor = tutorial::CalculatorProcessor->new($handler);
|
||||
my $serversocket = Thrift::ServerSocket->new(9090);
|
||||
my $forkingserver = Thrift::ForkingServer->new($processor, $serversocket);
|
||||
print "Starting the server...\n";
|
||||
$forkingserver->serve();
|
||||
print "done.\n";
|
||||
|
|
13
vendor/git.apache.org/thrift.git/tutorial/rs/src/bin/tutorial_client.rs
generated
vendored
13
vendor/git.apache.org/thrift.git/tutorial/rs/src/bin/tutorial_client.rs
generated
vendored
|
@ -22,8 +22,9 @@ extern crate thrift;
|
|||
extern crate thrift_tutorial;
|
||||
|
||||
use thrift::protocol::{TCompactInputProtocol, TCompactOutputProtocol};
|
||||
use thrift::transport::{ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel,
|
||||
TTcpChannel, WriteHalf};
|
||||
use thrift::transport::{
|
||||
ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel, TTcpChannel, WriteHalf,
|
||||
};
|
||||
|
||||
use thrift_tutorial::shared::TSharedServiceSyncClient;
|
||||
use thrift_tutorial::tutorial::{CalculatorSyncClient, Operation, TCalculatorSyncClient, Work};
|
||||
|
@ -70,8 +71,7 @@ fn run() -> thrift::Result<()> {
|
|||
let logid = 32;
|
||||
|
||||
// let's do...a multiply!
|
||||
let res = client
|
||||
.calculate(logid, Work::new(7, 8, Operation::MULTIPLY, None))?;
|
||||
let res = client.calculate(logid, Work::new(7, 8, Operation::Multiply, None))?;
|
||||
println!("multiplied 7 and 8 and got {}", res);
|
||||
|
||||
// let's get the log for it
|
||||
|
@ -81,7 +81,7 @@ fn run() -> thrift::Result<()> {
|
|||
// ok - let's be bad :(
|
||||
// do a divide by 0
|
||||
// logid doesn't matter; won't be recorded
|
||||
let res = client.calculate(77, Work::new(2, 0, Operation::DIVIDE, "we bad".to_owned()));
|
||||
let res = client.calculate(77, Work::new(2, 0, Operation::Divide, "we bad".to_owned()));
|
||||
|
||||
// we should have gotten an exception back
|
||||
match res {
|
||||
|
@ -103,8 +103,7 @@ fn run() -> thrift::Result<()> {
|
|||
type ClientInputProtocol = TCompactInputProtocol<TFramedReadTransport<ReadHalf<TTcpChannel>>>;
|
||||
type ClientOutputProtocol = TCompactOutputProtocol<TFramedWriteTransport<WriteHalf<TTcpChannel>>>;
|
||||
|
||||
fn new_client
|
||||
(
|
||||
fn new_client(
|
||||
host: &str,
|
||||
port: u16,
|
||||
) -> thrift::Result<CalculatorSyncClient<ClientInputProtocol, ClientOutputProtocol>> {
|
||||
|
|
41
vendor/git.apache.org/thrift.git/tutorial/rs/src/bin/tutorial_server.rs
generated
vendored
41
vendor/git.apache.org/thrift.git/tutorial/rs/src/bin/tutorial_server.rs
generated
vendored
|
@ -65,7 +65,9 @@ fn run() -> thrift::Result<()> {
|
|||
let o_prot_fact = TCompactOutputProtocolFactory::new();
|
||||
|
||||
// demux incoming messages
|
||||
let processor = CalculatorSyncProcessor::new(CalculatorServer { ..Default::default() });
|
||||
let processor = CalculatorSyncProcessor::new(CalculatorServer {
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
// create the server and start listening
|
||||
let mut server = TServer::new(
|
||||
|
@ -87,7 +89,9 @@ struct CalculatorServer {
|
|||
|
||||
impl Default for CalculatorServer {
|
||||
fn default() -> CalculatorServer {
|
||||
CalculatorServer { log: Mutex::new(HashMap::new()) }
|
||||
CalculatorServer {
|
||||
log: Mutex::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,29 +126,25 @@ impl CalculatorSyncHandler for CalculatorServer {
|
|||
|
||||
let res = if let Some(ref op) = w.op {
|
||||
if w.num1.is_none() || w.num2.is_none() {
|
||||
Err(
|
||||
InvalidOperation {
|
||||
what_op: Some(*op as i32),
|
||||
why: Some("no operands specified".to_owned()),
|
||||
},
|
||||
)
|
||||
Err(InvalidOperation {
|
||||
what_op: Some(*op as i32),
|
||||
why: Some("no operands specified".to_owned()),
|
||||
})
|
||||
} else {
|
||||
// so that I don't have to call unwrap() multiple times below
|
||||
let num1 = w.num1.as_ref().expect("operands checked");
|
||||
let num2 = w.num2.as_ref().expect("operands checked");
|
||||
|
||||
match *op {
|
||||
Operation::ADD => Ok(num1 + num2),
|
||||
Operation::SUBTRACT => Ok(num1 - num2),
|
||||
Operation::MULTIPLY => Ok(num1 * num2),
|
||||
Operation::DIVIDE => {
|
||||
Operation::Add => Ok(num1 + num2),
|
||||
Operation::Subtract => Ok(num1 - num2),
|
||||
Operation::Multiply => Ok(num1 * num2),
|
||||
Operation::Divide => {
|
||||
if *num2 == 0 {
|
||||
Err(
|
||||
InvalidOperation {
|
||||
what_op: Some(*op as i32),
|
||||
why: Some("divide by 0".to_owned()),
|
||||
},
|
||||
)
|
||||
Err(InvalidOperation {
|
||||
what_op: Some(*op as i32),
|
||||
why: Some("divide by 0".to_owned()),
|
||||
})
|
||||
} else {
|
||||
Ok(num1 / num2)
|
||||
}
|
||||
|
@ -152,7 +152,10 @@ impl CalculatorSyncHandler for CalculatorServer {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
Err(InvalidOperation::new(None, "no operation specified".to_owned()),)
|
||||
Err(InvalidOperation::new(
|
||||
None,
|
||||
"no operation specified".to_owned(),
|
||||
))
|
||||
};
|
||||
|
||||
// if the operation was successful log it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue