# @enmeshed/mesh-reflection

> Tools to inspect the state and membership of a service mesh.

Latest version **0.2.4** (published 2021-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @enmeshed/mesh-reflection
pnpm add @enmeshed/mesh-reflection
yarn add @enmeshed/mesh-reflection
bun add @enmeshed/mesh-reflection
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2021-05-30 |
| First published | 2019-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 81.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | wcjohnson |

## Links

- npm: https://www.npmjs.com/package/@enmeshed/mesh-reflection
- npm.io page: https://npm.io/package/@enmeshed/mesh-reflection

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.3.1
- [p-defer](https://npm.io/package/p-defer.md) ^3.0.0
- [lodash.isequal](https://npm.io/package/lodash.isequal.md) ^4.5.0

## Recent versions

- 0.2.4 (latest) — 2021-05-30
- 0.2.3 — 2020-07-18
- 0.2.2 — 2020-01-21
- 0.2.1 — 2019-11-25
- 0.2.0 — 2019-08-10
- 0.1.3 — 2019-08-07
- 0.1.2 — 2019-08-05
- 0.1.1 — 2019-08-02

## README

# @enmeshed/mesh-reflection

Allows members of a service mesh to obtain information about the available services in the mesh.

## Architecture

### Domain

All activity takes place in a `ReflectionDomain`, which is a root-level container for all of the below-mentioned resources.

#### API
```js
import { ReflectionDomain } from '@enmeshed/mesh-reflection'
```

```js
new ReflectionDomain(dataSource: DataSource)
```
Construct a new `ReflectionDomain` whose contents are provided by the given source.

```js
environment: Environment = domain.getEnvironment(name: string)
```
Retrieves a named `Environment` contained within the domain.

### DataSource

The domain has exactly one `DataSource`. A `DataSource` collects data from the cluster and prepares a collection of `Resource`s that are available for consumers to inspect. The `DataSource` writes these resources into a local, non-persistent store contained within the domain. **Only the `DataSource` is allowed to mutate the store**, so a correctly implemented `DataSource` can guarantee consumers have a consistent view of the resources in the mesh.

### Environment

Each domain has zero or more `Environment`s identified by string names unique within the domain. An `Environment` is in turn a container for `Resource`s which can be configured differently for each `Environment`. (Examples of `Environment`s might be `staging` and `live`, where services would be configured differently for each.)

The `Environment` also contains a map associating each `Service` with zero or one `Provider`s. This allows consumers to locate and connect to services on the mesh.

Consumers may enumerate and query resources, as well as listen for changes with node `EventEmitter` api. Further details below.

### Resource

`Resource`s come in two kinds, `Service`s and `Provider`s. Resources are identified by a string name which must be unique across the domain among resources of the same kind. Each `Resource` carries with it an arbitrary JSON metadata payload.

This library is unopinionated about the contents of the payload, but typically a `Service` would contain information about how it is expected to communicate with that service (for example, a service might idenitfy itself as gRPC and provide a list of acceptable protocol buffers) and a `Provider` would contain information about where to find that service (e.g. a cluster DNS address of the gRPC server)

---
_Source: https://npm.io/package/@enmeshed/mesh-reflection · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
