Skip to content

Commit

Permalink
refactor(core): full dependencies management rewrite
Browse files Browse the repository at this point in the history
fix #108
  • Loading branch information
nfroidure committed Aug 15, 2023
1 parent 9936d33 commit e0d57df
Show file tree
Hide file tree
Showing 7 changed files with 2,272 additions and 3,178 deletions.
53 changes: 0 additions & 53 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
* [.toMermaidGraph(options)](#Knifecycle+toMermaidGraph) ⇒ <code>String</code>
* [.run(dependenciesDeclarations)](#Knifecycle+run) ⇒ <code>Promise</code>
* [.destroy()](#Knifecycle+destroy) ⇒ <code>Promise</code>
* [._getServiceDescriptor(siloContext, serviceName, options, serviceProvider)](#Knifecycle+_getServiceDescriptor) ⇒ <code>Promise</code>
* [._initializeServiceDescriptor(siloContext, serviceName, options)](#Knifecycle+_initializeServiceDescriptor) ⇒ <code>Promise</code>
* [._initializeDependencies(siloContext, serviceName, servicesDeclarations, options)](#Knifecycle+_initializeDependencies) ⇒ <code>Promise</code>

<a name="new_Knifecycle_new"></a>

Expand Down Expand Up @@ -164,56 +161,6 @@ $.run(['ENV'])
$.destroy()
})
```
<a name="Knifecycle+_getServiceDescriptor"></a>

### knifecycle.\_getServiceDescriptor(siloContext, serviceName, options, serviceProvider) ⇒ <code>Promise</code>
Initialize or return a service descriptor

**Kind**: instance method of [<code>Knifecycle</code>](#Knifecycle)
**Returns**: <code>Promise</code> - Service descriptor promise.

| Param | Type | Description |
| --- | --- | --- |
| siloContext | <code>Object</code> | Current execution silo context |
| serviceName | <code>String</code> | Service name. |
| options | <code>Object</code> | Options for service retrieval |
| options.injectorContext | <code>Boolean</code> | Flag indicating the injection were initiated by the $injector |
| options.autoloading | <code>Boolean</code> | Flag to indicating $autoload dependencies on the fly loading |
| serviceProvider | <code>String</code> | Service provider. |

<a name="Knifecycle+_initializeServiceDescriptor"></a>

### knifecycle.\_initializeServiceDescriptor(siloContext, serviceName, options) ⇒ <code>Promise</code>
Initialize a service descriptor

**Kind**: instance method of [<code>Knifecycle</code>](#Knifecycle)
**Returns**: <code>Promise</code> - Service dependencies hash promise.

| Param | Type | Description |
| --- | --- | --- |
| siloContext | <code>Object</code> | Current execution silo context |
| serviceName | <code>String</code> | Service name. |
| options | <code>Object</code> | Options for service retrieval |
| options.injectorContext | <code>Boolean</code> | Flag indicating the injection were initiated by the $injector |
| options.autoloading | <code>Boolean</code> | Flag to indicating $autoload dependendencies on the fly loading. |

<a name="Knifecycle+_initializeDependencies"></a>

### knifecycle.\_initializeDependencies(siloContext, serviceName, servicesDeclarations, options) ⇒ <code>Promise</code>
Initialize a service dependencies

**Kind**: instance method of [<code>Knifecycle</code>](#Knifecycle)
**Returns**: <code>Promise</code> - Service dependencies hash promise.

| Param | Type | Description |
| --- | --- | --- |
| siloContext | <code>Object</code> | Current execution silo siloContext |
| serviceName | <code>String</code> | Service name. |
| servicesDeclarations | <code>String</code> | Dependencies declarations. |
| options | <code>Object</code> | Options for service retrieval |
| options.injectorContext | <code>Boolean</code> | Flag indicating the injection were initiated by the $injector |
| options.autoloading | <code>Boolean</code> | Flag to indicating $autoload dependendencies on the fly loading. |

<a name="initInitializerBuilder"></a>

## initInitializerBuilder(services) ⇒ <code>Promise.&lt;function()&gt;</code>
Expand Down
24 changes: 14 additions & 10 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ It is designed to have a low footprint on services code.
at all since they are just simple functions with annotations
set as a property.

[See in context](./src/index.ts#L156-L172)
In fact, the Knifecycle API is aimed to allow to statically
build its services load/unload code once in production.

[See in context](./src/index.ts#L193-L212)



Expand All @@ -49,7 +52,7 @@ A service provider is full of state since its concern is
[encapsulate](https://en.wikipedia.org/wiki/Encapsulation_(computer_programming))
your application global states.

[See in context](./src/index.ts#L174-L183)
[See in context](./src/index.ts#L214-L223)



Expand Down Expand Up @@ -101,7 +104,7 @@ The first step to use `knifecycle` is to create a new

Initializers can be of three types:
- constants: a `constant` initializer resolves to
a constant value.
any constant value.
- services: a `service` initializer directly
resolve to the actual service it builds. It can
be objects, functions or litteral values.
Expand All @@ -110,14 +113,15 @@ Initializers can be of three types:
but also an optional `dispose` property exposing a
method to properly stop the service and a
`fatalErrorPromise` that will be rejected if an
unrecoverable error happens.
unrecoverable error happens allowing Knifecycle
to terminate.

Initializers can be declared as singletons. This means
that they will be instanciated once for all for each
executions silos using them (we will cover this
topic later on).
Initializers can be declared as singletons (constants are
of course only singletons). This means that they will be
instanciated once for all for each executions silos using
them (we will cover this topic later on).

[See in context](./src/index.ts#L250-L273)
[See in context](./src/index.ts#L302-L326)



Expand All @@ -133,7 +137,7 @@ Depending on your application design, you could run it
in only one execution silo or into several ones
according to the isolation level your wish to reach.

[See in context](./src/index.ts#L537-L547)
[See in context](./src/index.ts#L592-L602)



Expand Down
53 changes: 0 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,6 @@ is maybe the best feature of this library ;).
* [.toMermaidGraph(options)](#Knifecycle+toMermaidGraph) ⇒ <code>String</code>
* [.run(dependenciesDeclarations)](#Knifecycle+run) ⇒ <code>Promise</code>
* [.destroy()](#Knifecycle+destroy) ⇒ <code>Promise</code>
* [._getServiceDescriptor(siloContext, serviceName, options, serviceProvider)](#Knifecycle+_getServiceDescriptor) ⇒ <code>Promise</code>
* [._initializeServiceDescriptor(siloContext, serviceName, options)](#Knifecycle+_initializeServiceDescriptor) ⇒ <code>Promise</code>
* [._initializeDependencies(siloContext, serviceName, servicesDeclarations, options)](#Knifecycle+_initializeDependencies) ⇒ <code>Promise</code>

<a name="new_Knifecycle_new"></a>

Expand Down Expand Up @@ -561,56 +558,6 @@ $.run(['ENV'])
$.destroy()
})
```
<a name="Knifecycle+_getServiceDescriptor"></a>

### knifecycle.\_getServiceDescriptor(siloContext, serviceName, options, serviceProvider) ⇒ <code>Promise</code>
Initialize or return a service descriptor

**Kind**: instance method of [<code>Knifecycle</code>](#Knifecycle)
**Returns**: <code>Promise</code> - Service descriptor promise.

| Param | Type | Description |
| --- | --- | --- |
| siloContext | <code>Object</code> | Current execution silo context |
| serviceName | <code>String</code> | Service name. |
| options | <code>Object</code> | Options for service retrieval |
| options.injectorContext | <code>Boolean</code> | Flag indicating the injection were initiated by the $injector |
| options.autoloading | <code>Boolean</code> | Flag to indicating $autoload dependencies on the fly loading |
| serviceProvider | <code>String</code> | Service provider. |

<a name="Knifecycle+_initializeServiceDescriptor"></a>

### knifecycle.\_initializeServiceDescriptor(siloContext, serviceName, options) ⇒ <code>Promise</code>
Initialize a service descriptor

**Kind**: instance method of [<code>Knifecycle</code>](#Knifecycle)
**Returns**: <code>Promise</code> - Service dependencies hash promise.

| Param | Type | Description |
| --- | --- | --- |
| siloContext | <code>Object</code> | Current execution silo context |
| serviceName | <code>String</code> | Service name. |
| options | <code>Object</code> | Options for service retrieval |
| options.injectorContext | <code>Boolean</code> | Flag indicating the injection were initiated by the $injector |
| options.autoloading | <code>Boolean</code> | Flag to indicating $autoload dependendencies on the fly loading. |

<a name="Knifecycle+_initializeDependencies"></a>

### knifecycle.\_initializeDependencies(siloContext, serviceName, servicesDeclarations, options) ⇒ <code>Promise</code>
Initialize a service dependencies

**Kind**: instance method of [<code>Knifecycle</code>](#Knifecycle)
**Returns**: <code>Promise</code> - Service dependencies hash promise.

| Param | Type | Description |
| --- | --- | --- |
| siloContext | <code>Object</code> | Current execution silo siloContext |
| serviceName | <code>String</code> | Service name. |
| servicesDeclarations | <code>String</code> | Dependencies declarations. |
| options | <code>Object</code> | Options for service retrieval |
| options.injectorContext | <code>Boolean</code> | Flag indicating the injection were initiated by the $injector |
| options.autoloading | <code>Boolean</code> | Flag to indicating $autoload dependendencies on the fly loading. |

<a name="initInitializerBuilder"></a>

## initInitializerBuilder(services) ⇒ <code>Promise.&lt;function()&gt;</code>
Expand Down
Loading

0 comments on commit e0d57df

Please sign in to comment.