Skip to content

Commit

Permalink
Improve DSPS Readme and remove todos.
Browse files Browse the repository at this point in the history
Change-Id: Id82ad846dd566306d41db211d9ae9a9370192306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336540
Commit-Queue: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
  • Loading branch information
Dan Chevalier authored and Commit Queue committed Nov 16, 2023
1 parent dd03188 commit 272b9d2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 30 deletions.
27 changes: 27 additions & 0 deletions pkg/dart_service_protocol_shared/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2023, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 changes: 14 additions & 20 deletions pkg/dart_service_protocol_shared/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@

An unlisted package for sharing code for Service Events and stream management between Dart SDK internal services.
An unlisted package for sharing code for service events and stream management between Dart SDK internal services.

The Dart Developer Service and Dart Tooling Daemon are the main consumers of this package.

**Expected SLO**: this package is maintained for our own tooling; we may not be able to respond to all issues and may only address the ones that we ourselves encounter.

## Features
## Details

* Stream Manager
* Helpers for managing streams that listeners can subscribe to.
* Service Events
* Helpers for setting up services that clients can call methods from.

## Getting started

TODO(@CoderDake): List prerequisites and provide or point to information on how to
start using the package.
This package helps handle some of the plumbing required to setup client communication for a service. The main behavior that it helps with is:
- `StreamManager`
- allows a client to subscribe/cancel to a stream with `streamListen`/`streamCancel`.
- allows a client to post a message to a stream with `postEvent`.
- `Client`, an interface that ensures the client is equipped to:
- handle method requests with `sendRequest`.
- handle receiving a message sent to a stream with `streamNotify`.
- `ClientManager`, keeps track of clients connected to a service.
- `addClient` should be called when a client connects to your service.
- `removeClient` should be called when it disconnects.

## Usage

### Stream Manager
TODO(@CoderDake): add Stream Manager Usage

### Service Events
TODO(@CoderDake): add Service Event Usage

## Additional information

TODO(@CoderDake): Fill out Additional information
To see an example of how `dart_service_protocol_shared` is used see:
* [Dart Developer Service](https://github.com/dart-lang/sdk/tree/main/pkg/dds)

This file was deleted.

3 changes: 1 addition & 2 deletions pkg/dart_service_protocol_shared/lib/src/stream_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import 'client.dart';

/// Manages state related to stream subscriptions made by [Client]s.
abstract class StreamManager {
final _streamListeners =
<String, List<Client>>{}; // TODO should this be set of StreamClient?
final _streamListeners = <String, List<Client>>{};
List<Client>? getListenersFor({required String stream}) =>
_streamListeners[stream];

Expand Down
2 changes: 1 addition & 1 deletion pkg/dart_service_protocol_shared/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: dart_service_protocol_shared
description: A package that implements service extensions and stream managers.

version: 0.0.1-dev
version: 0.0.1
repository: https://github.com/dart-lang/sdk/tree/main/pkg/dart_service_protocol_shared

environment:
Expand Down

0 comments on commit 272b9d2

Please sign in to comment.