diff --git a/pkg/dart_service_protocol_shared/LICENSE b/pkg/dart_service_protocol_shared/LICENSE new file mode 100644 index 000000000000..4fd5739c6fe3 --- /dev/null +++ b/pkg/dart_service_protocol_shared/LICENSE @@ -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. diff --git a/pkg/dart_service_protocol_shared/README.md b/pkg/dart_service_protocol_shared/README.md index b144c38e0b0d..180c645e09c9 100644 --- a/pkg/dart_service_protocol_shared/README.md +++ b/pkg/dart_service_protocol_shared/README.md @@ -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) \ No newline at end of file diff --git a/pkg/dart_service_protocol_shared/example/dart_service_protocol_shared.dart b/pkg/dart_service_protocol_shared/example/dart_service_protocol_shared.dart deleted file mode 100644 index 1c1805b0bd86..000000000000 --- a/pkg/dart_service_protocol_shared/example/dart_service_protocol_shared.dart +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -void main() { - // TODO(CoderDake): Implement examples -} diff --git a/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart b/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart index 8e7b8ecd9c10..cd28cfc88443 100644 --- a/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart +++ b/pkg/dart_service_protocol_shared/lib/src/stream_manager.dart @@ -8,8 +8,7 @@ import 'client.dart'; /// Manages state related to stream subscriptions made by [Client]s. abstract class StreamManager { - final _streamListeners = - >{}; // TODO should this be set of StreamClient? + final _streamListeners = >{}; List? getListenersFor({required String stream}) => _streamListeners[stream]; diff --git a/pkg/dart_service_protocol_shared/pubspec.yaml b/pkg/dart_service_protocol_shared/pubspec.yaml index 13951c5360a6..bf2299f11147 100644 --- a/pkg/dart_service_protocol_shared/pubspec.yaml +++ b/pkg/dart_service_protocol_shared/pubspec.yaml @@ -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: