Skip to content

Commit 1cf52e5

Browse files
Merge pull request #137 from sebastianconcept/develop
Master merging improvements + v0.5.24
2 parents 2ce63a3 + 6b65116 commit 1cf52e5

30 files changed

+838
-554
lines changed

.github/workflows/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Unit Tests
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
unit-tests:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
smalltalk: [Pharo64-7.0]
11+
redis-version: [7]
12+
mongodb-version: ['4.4']
13+
name: ${{ matrix.smalltalk }}
14+
services:
15+
postgres:
16+
image: postgres:14
17+
env:
18+
POSTGRES_USER: postgres
19+
POSTGRES_HOST_AUTH_METHOD: trust
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
ports:
26+
- 5432:5432
27+
steps:
28+
- name: Start Redis
29+
uses: supercharge/[email protected]
30+
with:
31+
redis-version: ${{ matrix.redis-version }}
32+
- name: Start MongoDB
33+
uses: supercharge/[email protected]
34+
with:
35+
mongodb-version: ${{ matrix.mongodb-version }}
36+
mongodb-replica-set: test-rs
37+
- uses: actions/checkout@v2
38+
- uses: hpi-swa/setup-smalltalkCI@v1
39+
with:
40+
smalltalk-image: ${{ matrix.smalltalk }}
41+
- name: Load Image and Run Tests
42+
run: smalltalkci -s ${{ matrix.smalltalk }} .smalltalkci/.unit-tests.ston
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
timeout-minutes: 15
46+
- name: Upload coverage to Codecov
47+
uses: codecov/codecov-action@v1
48+
with:
49+
name: ${{matrix.os}}-${{matrix.smalltalk}}
50+
token: ${{ secrets.CODECOV_TOKEN }}

.smalltalk.ston

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SmalltalkCISpec {
2+
#loading : [
3+
SCIMetacelloLoadSpec {
4+
#baseline : 'Mapless',
5+
#directory : 'src',
6+
#load : [ 'Core',
7+
'Memory',
8+
'Postgres',
9+
'Mongo',
10+
'Redis'
11+
],
12+
#platforms : [ #pharo
13+
]
14+
}
15+
]
16+
}

.smalltalkci/.unit-tests.ston

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
SmalltalkCISpec {
2+
#loading : [
3+
SCIMetacelloLoadSpec {
4+
#baseline : 'Mapless',
5+
#directory : '../src',
6+
#load : [ 'Core',
7+
'Memory',
8+
'Postgres',
9+
'Mongo',
10+
'Redis' ],
11+
#platforms : [ #pharo ]
12+
}
13+
],
14+
#testing : {
15+
#coverage : {
16+
#packages : [
17+
'Mapless-Base-Core',
18+
'Mapless-Memory-Core',
19+
'Mapless-Postgres-Core',
20+
'Mapless-Mongo-Core',
21+
'Mapless-Redis-Core'
22+
],
23+
#format: #lcov
24+
}
25+
}
26+
}

README.md

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44

55
Schema-less persistence for Smalltalk with support for multiple backends.
66

7-
[![Release](https://img.shields.io/github/v/tag/sebastianconcept/Mapless?label=release)](https://github.com/sebastianconcept/Mapless/releases)
8-
![Tests](https://img.shields.io/badge/tests-178-green)
7+
[![Unit Tests](https://github.com/sebastianconcept/Mapless/actions/workflows/build.yml/badge.svg)](https://github.com/sebastianconcept/Mapless/actions/workflows/build.yml)
8+
![Tests](https://img.shields.io/badge/tests-193-green)
9+
[![Coverage Status](https://codecov.io/github/sebastianconcept/Mapless/coverage.svg?branch=main)](https://codecov.io/gh/sebastianconcept/Mapless/branch/master)
10+
911
[![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE.txt)
12+
[![Release](https://img.shields.io/github/v/tag/sebastianconcept/Mapless?label=release)](https://github.com/sebastianconcept/Mapless/releases)
13+
14+
15+
[![Pharo 7](https://img.shields.io/badge/Pharo-7-%23383932.svg)](https://pharo.org/download)
16+
[![Pharo 10](https://img.shields.io/badge/Pharo-10-%23383932.svg)](https://pharo.org/download)
1017

1118
[![Social](https://img.shields.io/github/stars/sebastianconcept/Mapless?style=social)]()
1219
[![Forks](https://img.shields.io/github/forks/sebastianconcept/Mapless?style=sociall)]()
13-
[![](https://img.shields.io/reddit/subreddit-subscribers/mapless_data?style=social)](https://www.reddit.com/r/mapless_data/)
1420

1521
---
1622

@@ -21,62 +27,84 @@ Schema-less persistence for Smalltalk with support for multiple backends.
2127
- Composable.
2228
- JSON friendly.
2329
- No need to create accessors and mutators.
24-
- Multiple backends to chose from.
30+
- Multiple backends to choose from.
2531
- Enables smooth data migration/interoperation among backends.
26-
- Via Redis PUB/SUB, scalable observer-pattern functionality across images.
32+
- ~~Via Redis PUB/SUB, scalable observer-pattern functionality across images.~~ In the roadmap.
33+
34+
## Description
35+
36+
Mapless is a schema-less persistence framework supporting multiple backends and offering a user-friendly API. For instance, querying Mapless objects involves a common family of methods, and there's no need to declare accessors and mutators. See [examples below](#examples).
37+
38+
Designed to be schema-less, Mapless eliminates the need for schema maintenance and avoids any Object-Relational Mapping requirements.
39+
40+
Mapless achieves a balance of maximum data survivability and robust architectural flexibility without imposing a heavy burden in terms of adoption and maintenance.
2741

2842
## Ambition
2943

30-
Mapless gives you performant state plasticity and high availability in a scale that goes beyond one Smalltalk image and without backend vendor locking nor object-mapping impedance mismatch.
44+
To deliver a high-performance solution that preserves arbitrary application state (data) with a focus on flexibility, availability, and capacity. It aims to strategically aid in scaling without causing backend vendor lock-in, across various persistence backends, and by neutralizing the costs associated with object-mapping impedance mismatch.
3145

3246
## Supported backends
3347

3448
1. MongoDB
3549
2. Redis
3650
3. Memory
3751
4. PostgreSQL
38-
5. UnQLite
52+
5. ~~UnQLite~~ `deprecated` / retiring soon
3953

4054
## Examples
4155

4256
```Smalltalk
4357
"Instanciates a mapless object."
44-
genius := DummyPerson new
58+
philosopher := Person new
4559
firstName: 'Aristotle';
4660
yourself.
4761
4862
"Saves it."
49-
repository save: genius.
63+
repository save: philosopher.
5064
```
5165

5266
```Smalltalk
5367
"Loads one by known ID."
54-
identified := repository findOne: DummyPerson atId: genius id.
68+
identified := repository findOne: Person atId: philosopher id.
5569
```
5670

5771
```Smalltalk
5872
"Loads all instances of that class that were stored in that database."
59-
allOrEmpty := repository findAll: DummyPerson.
73+
allOrEmpty := repository findAll: Person.
6074
```
6175

6276
```Smalltalk
6377
"Query to load all the instances that match the condition."
64-
someOrEmpty := repository findAll: DummyPerson where: [ :each | each lastName = 'Peterson' ].
78+
someOrEmpty := repository findAll: Person where: [ :each | each lastName = 'Peterson' ].
6579
```
6680

6781
```Smalltalk
6882
"Conditionally loading the first matching instance."
69-
oneOrNil := repository findOne: DummyPerson where: [ :each | each lastName = 'Peterson' ].
83+
oneOrNil := repository findOne: Person where: [ :each | each lastName = 'Peterson' ].
7084
```
7185

86+
```Smalltalk
87+
"Create a Person mapless model"
88+
philosopher := Person new
89+
firstName: 'Aristotle';
90+
save.
91+
92+
"Set it as the person for a new User mapless model"
93+
philosopherUser := User new
94+
person: philosopher;
95+
save.
96+
97+
"Query for that user by ID and get its person instance"
98+
aristotle := (User findId: philosopherUser id) person.
99+
```
72100
## Installation
73101

74-
Open a Pharo workspace and evaluate:
102+
Open a workspace in a supported Pharo image and evaluate:
75103

76104
```smalltalk
77105
Metacello new
78106
baseline: 'Mapless';
79-
repository: 'github://sebastianconcept/Mapless:v0.5.4-beta/src';
107+
repository: 'github://sebastianconcept/Mapless:latest/src';
80108
load
81109
```
82110

@@ -88,6 +116,6 @@ In BaselineOf or ConfigurationOf it can be added in this way:
88116
spec
89117
baseline: 'Mapless'
90118
with: [ spec
91-
repository: 'github://sebastianconcept/Mapless:v0.5.0-alpha/src';
92-
loads: #('Core' 'Mongo' 'Memory' 'Redis' 'UnQLite') ]
119+
repository: 'github://sebastianconcept/Mapless:latest/src';
120+
load: #('Core' 'Postgres' 'Mongo' 'Redis' 'Memory') ]
93121
```

changelog.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Jan 25, 2024
2+
===================================
3+
- Updating `master` branch to keep up with the latests useful upgrades.
4+
- Adding badges to the README.md for constant monitoring of CI, unit tests, regression detection capacity and supported Pharo versions.
5+
- Adds CI via GitHub actions.
6+
7+
May 22, 2023
8+
===================================
9+
- Improved `MongoAPI` by adding `initializeMongoUrl` and a lazy accessor using it and `Array` instead of `Set` so comparing it on the fly from `getIdleReadOnlyClient` is significantly faster now.
10+
- `MaplessWeightedRandomPolicy>>nextAmong:` is faster now by not using `includes:` and use a `anySatisfy:` filter instead.
11+
12+
May 19, 2023
13+
===================================
14+
- Added `defaultMinClients` for `MaplessStandaloneMongoPool`.
15+
116
May 19, 2022 | v0.5.4-beta | Humble Falcon
217
===================================
318
- `MongoChange` is now using MongoDB `document` instead of `jsonish`.

src/BaselineOfMapless/BaselineOfMapless.class.st

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ BaselineOfMapless >> baseline: spec [
4343
{ #category : #baseline }
4444
BaselineOfMapless >> setUpBaseDependencies: spec [
4545
spec
46-
baseline: 'JSONExtensions'
47-
with: [ spec repository: 'github://sebastianconcept/JSONExtensions/src' ].
46+
baseline: 'JSON'
47+
with: [ spec repository: 'github://sebastianconcept/JSON:v1.0.2/src' ].
4848
spec
4949
baseline: 'NeoJSON'
5050
with: [ spec repository: 'github://svenvc/NeoJSON:master/repository' ]
@@ -54,7 +54,7 @@ BaselineOfMapless >> setUpBaseDependencies: spec [
5454
BaselineOfMapless >> setUpBasePackages: spec [
5555
spec
5656
package: 'Mapless-Base-Core'
57-
with: [ spec requires: 'JSONExtensions' ].
57+
with: [ spec requires: 'JSON' ].
5858
spec
5959
package: 'Mapless-Tests-Base'
6060
with: [ spec requires: 'Mapless-Base-Core' ].

src/Mapless-Base-Core/MaplessError.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Class {
22
#name : #MaplessError,
3-
#superclass : #Exception,
3+
#superclass : #Error,
44
#category : #'Mapless-Base-Core-Errors'
55
}
66

src/Mapless-Base-Core/MaplessRepository.class.st

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ MaplessRepository >> asStorable: anObject [
6464
ifTrue: [ (resolver asMaplessReferenceIn: anObject in: self)
6565
asJsonObjectIn: self ]
6666
ifFalse: [ anObject ] ]
67-
ifTrue: [
68-
anObject hasModel
69-
ifTrue: [ resolver maplessReferenceAsJsonObject: anObject in: self ]
70-
ifFalse: [ MaplessUnsavedSubmodel
67+
ifTrue: [ (anObject hasModel and: [ anObject data id isNil ])
68+
ifFalse: [ resolver maplessReferenceAsJsonObject: anObject in: self ]
69+
ifTrue: [ MaplessUnsavedSubmodel
7170
signal:
7271
'This sub model is unsaved. You need to save all sub models before saving a composed model' ] ] ]
7372
]

src/Mapless-Base-Core/MaplessWeightedRandomPolicy.class.st

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ MaplessWeightedRandomPolicy >> next [
6868
{ #category : #actions }
6969
MaplessWeightedRandomPolicy >> nextAmong: values [
7070
| nextOne |
71-
[ nextOne isNil or: [ (values includes: nextOne value) not ] ]
72-
whileTrue: [ nextOne := self next ].
71+
nextOne := self next.
72+
[ (values
73+
anySatisfy:
74+
[ :url | url port = nextOne value port and: [ url host = nextOne value host ] ])
75+
not ] whileTrue: [ nextOne := self next ].
7376
^ nextOne value
7477
]
7578

src/Mapless-Memory-Core/MaplessMemoryAccessor.class.st

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ MaplessMemoryAccessor >> do: aBlock [
2222
^ aBlock value
2323
]
2424

25+
{ #category : #testing }
26+
MaplessMemoryAccessor >> hasHealthChecker [
27+
^ false
28+
]
29+
2530
{ #category : #operations }
2631
MaplessMemoryAccessor >> initialize [
2732
super initialize.

0 commit comments

Comments
 (0)