A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
native_objects.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef A11_WASM_NATIVE_OBJECTS_H_
16#define A11_WASM_NATIVE_OBJECTS_H_
17
18#include <memory>
19#include <string>
20#include <vector>
21
22#include <absl/container/flat_hash_map.h>
23#include <absl/container/flat_hash_set.h>
24#include <absl/status/status.h>
25
26#include "a11/actions/action.h"
28#include "a11/nodes/node_map.h"
29#include "a11/service/session.h"
31#include "graph_snapshot.h"
32#include "host_settings.h"
33#include "host_stream.h"
34#include "host_binary_channel.h"
36
37namespace a11::wasm {
38
40 std::shared_ptr<nodes::NodeMap> nodes;
41 std::shared_ptr<StoreRegistry> stores;
42 std::shared_ptr<actions::ActionRegistry> registry;
44 bool initialized ABSL_GUARDED_BY(mu) = false;
45 bool importing_snapshot ABSL_GUARDED_BY(mu) = false;
46 absl::Status startup ABSL_GUARDED_BY(mu);
48 std::string storage_id ABSL_GUARDED_BY(mu) = "local";
49 absl::flat_hash_map<std::string, std::shared_ptr<actions::Action>>
51 absl::flat_hash_map<std::string, std::shared_ptr<service::Session>>
53 std::vector<std::shared_ptr<nodes::NodeMap>> flow_nodes ABSL_GUARDED_BY(mu);
54 absl::flat_hash_map<std::string, std::shared_ptr<nodes::NodeMap>>
55 retained_flows ABSL_GUARDED_BY(mu);
56 absl::flat_hash_map<std::string, std::shared_ptr<HostStreamPair>>
57 host_streams ABSL_GUARDED_BY(mu);
58 absl::flat_hash_set<std::string> pending_host_streams ABSL_GUARDED_BY(mu);
59 absl::flat_hash_map<std::string, std::shared_ptr<HostBinaryChannel>>
60 binary_channels ABSL_GUARDED_BY(mu);
61 absl::flat_hash_map<std::string, std::shared_ptr<HostChannelWireStream>>
62 channel_streams ABSL_GUARDED_BY(mu);
63 absl::flat_hash_map<std::string,
64 std::shared_ptr<net::WireStreamWithRecv>>
65 channel_receivers ABSL_GUARDED_BY(mu);
66};
67
69 std::shared_ptr<NativeGraph> graph;
70};
71
72absl::Status RegisterHostAction(actions::ActionRegistry& registry,
74 const std::shared_ptr<NativeGraph>& graph);
75
76absl::Status HostInvokeSessionCallback(const std::string& session_id,
77 const std::string& payload);
78
79} // namespace a11::wasm
80
81#endif // A11_WASM_NATIVE_OBJECTS_H_
A11's unit of work: the Action and its supporting types.
std::string session_id
Definition authorization.cc:217
A thread-safe catalogue mapping action names to schema and handler.
Definition registry.h:59
Definition boost_primitives.h:21
Definition async_task.cc:27
absl::Status HostInvokeSessionCallback(const std::string &session_id, const std::string &payload)
Definition bridge_native.cc:436
absl::Status RegisterHostAction(actions::ActionRegistry &registry, actions::ActionSchema schema, const std::shared_ptr< NativeGraph > &graph)
Definition bridge_native.cc:430
A registry of AsyncNodes keyed by node id.
The action registry: a catalogue of named schema/handler pairs.
A11's connection-scoped runtime: the Session.
The full typed interface of an action.
Definition schema.h:144
Definition host_settings.h:27
Definition native_objects.h:39
bool initialized ABSL_GUARDED_BY(mu)
absl::flat_hash_set< std::string > pending_host_streams ABSL_GUARDED_BY(mu)
absl::flat_hash_map< std::string, std::shared_ptr< actions::Action > > actions ABSL_GUARDED_BY(mu)
HostSettings host_settings ABSL_GUARDED_BY(mu)
std::shared_ptr< actions::ActionRegistry > registry
Definition native_objects.h:42
std::shared_ptr< StoreRegistry > stores
Definition native_objects.h:41
absl::flat_hash_map< std::string, std::shared_ptr< net::WireStreamWithRecv > > channel_receivers ABSL_GUARDED_BY(mu)
absl::flat_hash_map< std::string, std::shared_ptr< nodes::NodeMap > > retained_flows ABSL_GUARDED_BY(mu)
absl::flat_hash_map< std::string, std::shared_ptr< service::Session > > sessions ABSL_GUARDED_BY(mu)
std::string storage_id ABSL_GUARDED_BY(mu)
absl::Status startup ABSL_GUARDED_BY(mu)
absl::flat_hash_map< std::string, std::shared_ptr< HostChannelWireStream > > channel_streams ABSL_GUARDED_BY(mu)
std::vector< std::shared_ptr< nodes::NodeMap > > flow_nodes ABSL_GUARDED_BY(mu)
absl::flat_hash_map< std::string, std::shared_ptr< HostStreamPair > > host_streams ABSL_GUARDED_BY(mu)
bool importing_snapshot ABSL_GUARDED_BY(mu)
absl::flat_hash_map< std::string, std::shared_ptr< HostBinaryChannel > > binary_channels ABSL_GUARDED_BY(mu)
thread::Mutex mu
Definition native_objects.h:43
std::shared_ptr< nodes::NodeMap > nodes
Definition native_objects.h:40
Definition native_objects.h:68
std::shared_ptr< NativeGraph > graph
Definition native_objects.h:69