Skip to content

Commit

Permalink
Merge pull request #49 from ba-st/update_dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
gcotelli authored Nov 25, 2021
2 parents fd87899 + dee037a commit 5d649ab
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 117 deletions.
4 changes: 2 additions & 2 deletions api-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ FROM basmalltalk/pharo:8.0

USER root

WORKDIR /opt/Superluminal-Service-Discovery-Example
WORKDIR /opt/app
COPY start.sh ./
COPY --from=loader /opt/pharo/Pharo.image ./
COPY --from=loader /opt/pharo/Pharo.changes ./
COPY --from=loader /opt/pharo/Pharo*.sources ./

RUN mkdir logs \
&& chmod a+x start.sh \
&& chown --recursive pharo:users /opt/Superluminal-Service-Discovery-Example
&& chown --recursive pharo:users /opt/app

USER pharo

Expand Down
8 changes: 3 additions & 5 deletions api-tests/start.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash

exec /opt/pharo/pharo \
/opt/Superluminal-Service-Discovery-Example/Pharo.image \
super-luminal-service-discovery \
--message="${MESSAGE}" \
--consul-agent-location="${CONSUL_AGENT_LOCATION}" \
--retry-delay-in-ms=10000
/opt/app/Pharo.image \
launchpad start superluminal-service-discovery \
--retry-delay-in-ms=10000
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BaselineOfSuperluminal >> setUpDependencies: spec [
with: [ spec loads: 'Dependent-SUnit-Extensions' ].

spec
baseline: 'Launchpad' with: [ spec repository: 'github://ba-st/Launchpad:v3' ];
baseline: 'Launchpad' with: [ spec repository: 'github://ba-st/Launchpad:v4' ];
project: 'Launchpad-Deployment' copyFrom: 'Launchpad' with: [ spec loads: 'Deployment' ].

spec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,67 @@ Class {
{ #category : #tests }
SuperluminalServiceDiscoveryExampleLauncherTest >> testActivate [

self
should: [
| launcher |

launcher := SuperluminalServiceDiscoveryExampleLauncher new.
launcher
commandLine: ( CommandLineArguments withArguments:
#( '--consul-agent-location=http://consul:8500'
'--message=Hello' '--retry-delay-in-ms=1' '--debug-mode' ) );
activate
]
raise: NameLookupFailure
| commandLine |

commandLine := CommandLineArguments withArguments:
#( 'launchpad' 'start' '--debug-mode' 'superluminal-service-discovery'
'--consul-agent-location=http://consul:8500'
'--message=Hello' '--retry-delay-in-ms=1' ).

self should: [ LaunchpadCommandLineHandler activateWith: commandLine ] raise: NameLookupFailure
]

{ #category : #tests }
SuperluminalServiceDiscoveryExampleLauncherTest >> testArguments [
SuperluminalServiceDiscoveryExampleLauncherTest >> testActivateInReleaseMode [

| launcher |
| commandLine |

launcher := SuperluminalServiceDiscoveryExampleLauncher new.
launcher commandLine: ( CommandLineArguments withArguments:
#( '--consul-agent-location=http://consul:8500' '--message=Hello' '--retry-delay-in-ms=1'
'--debug-mode' ) ).
commandLine := CommandLineArguments withArguments:
#( 'launchpad' 'start' 'superluminal-service-discovery'
'--consul-agent-location=http://consul:8500'
'--message=Hello' '--retry-delay-in-ms=1' ).

self
assert: launcher message equals: 'Hello';
assertUrl: launcher consulAgentLocation equals: 'http://consul:8500'
self should: [ LaunchpadCommandLineHandler activateWith: commandLine ]
raise: Exit
withExceptionDo: [ :exit | self deny: exit isSuccess ]
]

{ #category : #tests }
SuperluminalServiceDiscoveryExampleLauncherTest >> testCommandName [

self assert: SuperluminalServiceDiscoveryExampleLauncher commandName
equals: 'super-luminal-service-discovery'
self assert: SuperluminalServiceDiscoveryExample commandName
equals: 'superluminal-service-discovery'
]

{ #category : #tests }
SuperluminalServiceDiscoveryExampleLauncherTest >> testDescription [

self assert: SuperluminalServiceDiscoveryExampleLauncher description
self assert: SuperluminalServiceDiscoveryExample description
equals: 'I''m a command line example using as dependency an echo API'
]

{ #category : #tests }
SuperluminalServiceDiscoveryExampleLauncherTest >> testLogPrefix [
SuperluminalServiceDiscoveryExampleLauncherTest >> testHelp [

self assert: SuperluminalServiceDiscoveryExampleLauncher logPrefix
equals: 'Superluminal-Service-Discovery'
self assert:
( String streamContents: [ :stream | SuperluminalServiceDiscoveryExample printHelpOn: stream ] )
equals: 'NAME
superluminal-service-discovery [3.0.0] - I''m a command line example using as dependency an echo API
SYNOPSYS
superluminal-service-discovery --message=<message> --consul-agent-location=<consulAgentLocation> [--retry-delay-in-ms=<retryDelayInMs>]
PARAMETERS
--message=<message>
Message to echo.
--consul-agent-location=<consulAgentLocation>
Location of the Consul agent.
--retry-delay-in-ms=<retryDelayInMs>
Milliseconds to wait between retries. Defaults to 0:00:00:00.2.
ENVIRONMENT
MESSAGE
Message to echo.
CONSUL_AGENT_LOCATION
Location of the Consul agent.
RETRY_DELAY_IN_MS
Milliseconds to wait between retries. Defaults to 0:00:00:00.2.
'
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Class {
#name : #SuperluminalServiceDiscoveryExample,
#superclass : #LaunchpadApplication,
#category : #'Superluminal-Service-Discovery-Examples'
}

{ #category : #accessing }
SuperluminalServiceDiscoveryExample class >> commandName [

^ 'superluminal-service-discovery'
]

{ #category : #accessing }
SuperluminalServiceDiscoveryExample class >> configurationParameters [

^ Array
with: ( MandatoryConfigurationParameter named: 'Message' describedBy: 'Message to echo' )
with: ( MandatoryConfigurationParameter named: 'Consul Agent Location'
describedBy: 'Location of the Consul agent'
convertingWith: #asUrl )
with: ( OptionalConfigurationParameter named: 'Retry Delay in ms'
describedBy: 'Milliseconds to wait between retries'
defaultingTo: 200 milliSeconds
convertingWith: [ :parameter | parameter asNumber milliSeconds ] )
]

{ #category : #accessing }
SuperluminalServiceDiscoveryExample class >> description [

^ 'I''m a command line example using as dependency an echo API'
]

{ #category : #accessing }
SuperluminalServiceDiscoveryExample class >> version [

^ '3.0.0'
]

{ #category : #'private - activation' }
SuperluminalServiceDiscoveryExample >> basicStartWithin: context [

| consulAgentLocation echoServiceLocation |

consulAgentLocation := self configuration consulAgentLocation.
LaunchpadLogRecord emitInfo: 'Discovering dependencies' during: [
echoServiceLocation := Retry
value: [
( ConsulAgentHttpAPIBasedDiscoveryClient queryingAgentOn:
consulAgentLocation ) withLocationOfService: #echo
do: [ :location | location ]
ifUnable: [ Error signal: 'Cannot discover #echo service' ]
]
configuredBy: [ :retry |
retry
upTo: 3 timesEvery: self configuration retryDelayInMs;
on: Error evaluating: [ :attemptNumber :exception |
LaunchpadLogRecord emitWarning:
( 'Attempt #<1p> failed with error: <2s>' expandMacrosWith:
attemptNumber
with: exception messageText )
]
]
].

RESTfulAPIClient cachingOnLocalMemory
get: ( echoServiceLocation
scheme: #http;
addPathSegment: 'echo';
addPathSegment: self configuration message;
yourself )
withSuccessfulResponseDo: [ :response |
response = self configuration message asUppercase ifFalse: [ Error signal: 'Invalid response received' ] ].

self exitSuccess
]

{ #category : #'error handling' }
SuperluminalServiceDiscoveryExample >> stackTraceDumper [

^ NullStackTraceDumper new
]

This file was deleted.

0 comments on commit 5d649ab

Please sign in to comment.