Skip to content

Commit

Permalink
Merge pull request #41 from zweidenker/Fix-broken-dependencies
Browse files Browse the repository at this point in the history
extracted dummyContextSnapshot as a Core  method so that it can be ac…
  • Loading branch information
noha authored Jan 30, 2020
2 parents 11a3fb5 + f20b799 commit 7dcd1da
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 55 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Quick start
-----------
SnapDump is available as docker application for easy deployment. Let's pull a stable version of the SnapDump server (check DockerHub to be up to date):

$ docker pull zweidenker/snap-dump:0.7
$ docker pull zweidenker/snap-dump:0.7.3

To keep the snapshots on server restart we need to create a volume where snapshots can be stored. You do this by invoking:

$ docker volume create SnapDump

SnapDump uses internally the port 5555 for the server. This can be mapped to a local port on the host by specifying on the docker commandline. To start the server with that port and the former created volume invoke:

$ docker run -p 8888:5555 -v SnapDump:/snapshots zweidenker/snap-dump:0.7
$ docker run -p 8888:5555 -v SnapDump:/snapshots zweidenker/snap-dump:0.7.3

Now our SnapDump server is up and running, we would like to first: report exceptions from a SnapDump handler image , and second: retrieve our reported exceptions on a SnapDump client image.

Expand All @@ -37,7 +37,7 @@ To download a pharo image from command line you can use:
To install SnapDump open a playground and execute:

Metacello new
repository: 'github://zweidenker/SnapDump:0.7';
repository: 'github://zweidenker/SnapDump:0.7.3';
baseline: #SnapDump;
load

Expand All @@ -47,18 +47,17 @@ To configure Snapdump on the handler image execute:

SnapDump hackUIManager; beHandler.
SnapDump uri: 'http://localhost:8888/api'.
SnapDump current projectName: 'projectname1' versionString: '0.7'.
SnapDump current projectName: 'projectname1' versionString: '0.7.3'.

This could be executed systematically when the image is deployed and starts.

Then to report an exception to our SnapDump server, use #SnapDump>>handleException: in the likes of:

[Error signal: 'My first SnapDump snapshot']
on: Error
do: [ :error |
Smalltalk
at: #SnapDump
ifPresent: [ :reporter | reporter handleException: error ] ]
```smalltalk
SnapDump handleException: SDSnapshot dummyContext
```
Here we are using a tiny sample context object for the purpose of testing SnapDump.
Usually, one would catch a concrete Error object and report it using #handleException:

On the SnapDump client image
----------------------------
Expand Down
20 changes: 0 additions & 20 deletions source/SnapDump-Core-Tests/SDHandler.extension.st

This file was deleted.

25 changes: 1 addition & 24 deletions source/SnapDump-Core-Tests/SDTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,11 @@ SDTests >> createSimpleSnapshot [

]

{ #category : #'as yet unclassified' }
SDTests >> dummyContext [
| context |
context := (Context newForMethod: Object >> #printStringLimitedTo:).
context
initializeWith: 23
stackPtr: 1
method: Object >> #printStringLimitedTo:
receiver: 'TestString'
sender: ((Context newForMethod: Object >> #printString)
initializeWith: 23
stackPtr: 1
method: Object >> #printString
receiver: 'TestString'
sender: ((Context newForMethod: Object >> #asString)
initializeWith: 23
stackPtr: 1
method: Object >> #asString
receiver: 'TestString'
sender: nil)).
^ context
]

{ #category : #'as yet unclassified' }
SDTests >> dummyContextSnapshot [

| snapshot |
snapshot := self dummyContext asSnapshot.
snapshot := SDSnapshot dummyContextSnapshot.
snapshot exception instVarNamed: #id put: self dummyExceptionId.
snapshot
instVarNamed: #exceptionId put: self dummyExceptionId;
Expand Down
31 changes: 30 additions & 1 deletion source/SnapDump-Core/SDSnapshot.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,41 @@ SDSnapshot class >> apiVersion [
^ 'v2'
]

{ #category : #accessing }
SDSnapshot class >> dummyContext [
| context |
context := (Context newForMethod: Object >> #printStringLimitedTo:).
context
initializeWith: 23
stackPtr: 1
method: Object >> #printStringLimitedTo:
receiver: 'TestString'
sender: ((Context newForMethod: Object >> #printString)
initializeWith: 23
stackPtr: 1
method: Object >> #printString
receiver: 'TestString'
sender: ((Context newForMethod: Object >> #asString)
initializeWith: 23
stackPtr: 1
method: Object >> #asString
receiver: 'TestString'
sender: nil)).
^ context
]

{ #category : #accessing }
SDSnapshot class >> dummyContextSnapshot [

^ self dummyContext asSnapshot
]

{ #category : #'as yet unclassified' }
SDSnapshot class >> exception: anException [
^ self new exception: anException
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SDSnapshot class >> metaSeparator [
^ 255
]
Expand Down
16 changes: 16 additions & 0 deletions source/SnapDump-Handler/SDHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ Class {
#category : #'SnapDump-Handler'
}

{ #category : #'as yet unclassified' }
SDHandler class >> fillExamples [
| handler |
handler := SDHandler new
store: SnapDump current store.

1 to: 2 do: [:x| | snapshot |
1 to: 2 do: [ :y |
1 to: 2 do: [ :z |
handler
projectName: ('projectname', x asString)
versionString: '1.', y asString.
snapshot := SDSnapshot dummyContextSnapshot.
handler handleSnapshot: snapshot ] ] ]
]

{ #category : #accessing }
SDHandler class >> type [
^ #handler
Expand Down

0 comments on commit 7dcd1da

Please sign in to comment.