blob: 62a7c13909a08304d0f3c583e2e7fccb795d7fbd [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.modular;
using fuchsia.sys;
using zx;
/// Provided to all component instances in their incoming namespace.
@discoverable
protocol ComponentContext {
/// DEPRECATED: use the component's incoming namespace (for C++, see sys.ComponentContext)
/// to connect to services provided by agents. See
/// /docs/concepts/modular/guide/how_to_write_an_agent_cc.md for an example.
///
/// Used to start an agent in the user scope if it isn't already running, and
/// connect to it.
@transitional
DeprecatedConnectToAgent(resource struct {
url string:MAX;
incoming_services server_end:fuchsia.sys.ServiceProvider;
controller server_end:AgentController;
});
/// DEPRECATED: use the component's incoming namespace (for C++, see sys.ComponentContext)
/// to connect to services provided by agents. See
/// /docs/concepts/modular/guide/how_to_write_an_agent_cc.md for an example.
///
/// Connects to an agent that provides the given `request.service_name`, and
/// then connects the given `request.channel` to that service.
///
/// If an error is encountered, the `request.channel` will be closed with
/// a status code, such as:
/// * `ZX_ERR_NOT_FOUND` -- if a `request.handler` agent URL is not
/// specified, and an agent for the `request.service_name` is not found
/// * `ZX_ERR_PEER_CLOSED` -- if `request.service_name` is not available from
/// the agent (either specified or discovered)
@transitional
DeprecatedConnectToAgentService(resource struct {
request AgentServiceRequest;
});
};
/// Used by ComponentContext.ConnectToAgentService
type AgentServiceRequest = resource table {
/// The name of the requested service.
1: service_name string:MAX;
/// The channel that will be used to communicate with the requested service.
2: channel zx.handle:CHANNEL;
/// The component URL of the Agent that is to provide the specified service.
/// If no handler is specified, the framework will perform resolution to
/// find an appropriate handler.
3: handler fuchsia.sys.component_url;
/// The AgentController handle is optional. If provided, the channel
/// will be kept open until the agent providing `service_name` is terminated.
4: agent_controller server_end:AgentController;
};