diff --git a/.github/workflows/deploy.synnax.yaml b/.github/workflows/deploy.synnax.yaml index 3a319b4220..b236a3a699 100644 --- a/.github/workflows/deploy.synnax.yaml +++ b/.github/workflows/deploy.synnax.yaml @@ -169,11 +169,11 @@ jobs: - name: Move Driver if: needs.setup.outputs.changed == 'true' - run: mv bazel-bin/driver/driver_main${{ steps.executable.outputs.EXECUTABLE }} synnax/pkg/hardware/embedded/assets/ + run: mv bazel-bin/driver/driver_main${{ steps.executable.outputs.EXECUTABLE }} synnax/pkg/service/hardware/embedded/assets/ - name: Rename Driver if: needs.setup.outputs.changed == 'true' - run: mv synnax/pkg/hardware/embedded/assets/driver_main${{ steps.executable.outputs.EXECUTABLE }} synnax/pkg/hardware/embedded/assets/driver${{ steps.executable.outputs.EXECUTABLE }} + run: mv synnax/pkg/service/hardware/embedded/assets/driver_main${{ steps.executable.outputs.EXECUTABLE }} synnax/pkg/service/hardware/embedded/assets/driver${{ steps.executable.outputs.EXECUTABLE }} - name: Set up Go diff --git a/.gitignore b/.gitignore index 7d17574a36..028a4af611 100644 --- a/.gitignore +++ b/.gitignore @@ -67,8 +67,8 @@ landing/ synnax-data/** -synnax/pkg/hardware/embedded/assets/** -!synnax/pkg/hardware/embedded/assets/.gitkeep +synnax/pkg/service/hardware/embedded/assets/** +!synnax/pkg/service/hardware/embedded/assets/.gitkeep # |||||| BAZEL |||||| # Ignore all bazel-* symlinks. There is no full list since this can change diff --git a/client/cpp/framer/BUILD.bazel b/client/cpp/framer/BUILD.bazel index a2e19bd91b..1dad7e743f 100644 --- a/client/cpp/framer/BUILD.bazel +++ b/client/cpp/framer/BUILD.bazel @@ -40,3 +40,19 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name ="streamer_test", + srcs = [ + "streamer_test.cpp" + ], + copts = select({ + "@platforms//os:windows": ["/std:c++20"], + "//conditions:default": [], + }), + deps = [ + "//client/cpp:synnax", + "//client/cpp/testutil", + "@com_google_googletest//:gtest_main", + ], +) \ No newline at end of file diff --git a/client/cpp/framer/framer.h b/client/cpp/framer/framer.h index ffc7e2fd7f..81f0d77ced 100644 --- a/client/cpp/framer/framer.h +++ b/client/cpp/framer/framer.h @@ -117,6 +117,7 @@ class StreamerConfig { public: /// @brief the channels to stream. std::vector channels; + int downsample_factor = 1; private: void toProto(api::v1::FrameStreamerRequest &f) const; diff --git a/client/cpp/framer/streamer.cpp b/client/cpp/framer/streamer.cpp index 7e0cc0ca4b..918c52ece9 100644 --- a/client/cpp/framer/streamer.cpp +++ b/client/cpp/framer/streamer.cpp @@ -17,6 +17,7 @@ using namespace synnax; void StreamerConfig::toProto(api::v1::FrameStreamerRequest &f) const { f.mutable_keys()->Add(channels.begin(), channels.end()); + f.set_downsample_factor(downsample_factor); } std::pair FrameClient::openStreamer( diff --git a/client/cpp/framer/streamer_test.cpp b/client/cpp/framer/streamer_test.cpp index 73d45d278b..e727ef5103 100644 --- a/client/cpp/framer/streamer_test.cpp +++ b/client/cpp/framer/streamer_test.cpp @@ -13,12 +13,17 @@ #include "client/cpp/synnax.h" #include "client/cpp/testutil/testutil.h" +void test_downsample( + std::vector raw_data, + std::vector expected, + int32_t downsample_factor +); /// @brief it should correctly receive a frame of streamed telemetry from the DB. TEST(FramerTests, testStreamBasic) { auto client = new_test_client(); auto [data, cErr] = client.channels.create( "data", - synnax::FLOAT32, + synnax::INT32, 1 * synnax::HZ); ASSERT_FALSE(cErr) << cErr.message(); auto now = synnax::TimeStamp::now(); @@ -35,20 +40,19 @@ TEST(FramerTests, testStreamBasic) { channels, }); - // Sleep for 5 milliseconds to allow for the streamer to bootstrap. std::this_thread::sleep_for(std::chrono::milliseconds(5)); auto frame = synnax::Frame(1); frame.add( data.key, - synnax::Series(std::vector{1.0})); + synnax::Series(std::vector{1})); ASSERT_TRUE(writer.write(std::move(frame))); auto [res_frame, recErr] = streamer.read(); ASSERT_FALSE(recErr) << recErr.message(); ASSERT_EQ(res_frame.size(), 1); - ASSERT_EQ(res_frame.series->at(0).values()[0], 1.0); + ASSERT_EQ(res_frame.series->at(0).values()[0], 1); auto wcErr = writer.close(); ASSERT_FALSE(cErr) << cErr.message(); @@ -85,7 +89,7 @@ TEST(FramerTests, testStreamSetChannels) { auto frame = synnax::Frame(1); frame.add( data.key, - synnax::Series(std::vector{1.0})); + synnax::Series(std::vector{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0})); ASSERT_TRUE(writer.write(std::move(frame))); auto [res_frame, recErr] = streamer.read(); ASSERT_FALSE(recErr) << recErr.message(); @@ -98,3 +102,146 @@ TEST(FramerTests, testStreamSetChannels) { auto wsErr = streamer.close(); ASSERT_FALSE(wsErr) << wsErr.message(); } + +/// @brief it should correctly receive a frame of streamed telemetry from the DB. +TEST(FramerTests, TestStreamDownsample) { + std::vector data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + + test_downsample(data,data,1); + + std::vector expected = {1, 3, 5, 7, 9}; + test_downsample(data, expected, 2); + + expected = {1, 4, 7, 10}; + test_downsample(data, expected, 3); + + expected = {1, 5, 9}; + test_downsample(data, expected, 4); + + expected = {1, 6}; + test_downsample(data, expected, 5); + + expected = {1, 7}; + test_downsample(data, expected, 6); + + expected = {1, 8}; + test_downsample(data, expected, 7); + + expected = {1, 9}; + test_downsample(data, expected, 8); + + expected = {1, 10}; + test_downsample(data, expected, 9); + + expected = {1}; + test_downsample(data, expected, 10); + + test_downsample(data, data,-1); + + test_downsample(data, data,0); +} + +void test_downsample( + std::vector raw_data, + std::vector expected, + int32_t downsample_factor +) { + auto client = new_test_client(); + auto [data, cErr] = client.channels.create( + "data", + synnax::INT32, + 1 * synnax::HZ); + ASSERT_FALSE(cErr) << cErr.message(); + auto now = synnax::TimeStamp::now(); + std::vector channels = {data.key}; + auto [writer, wErr] = client.telem.openWriter(synnax::WriterConfig{ + channels, + now, + std::vector{synnax::AUTH_ABSOLUTE}, + synnax::ControlSubject{"test_writer"} + }); + ASSERT_FALSE(wErr) << wErr.message(); + + auto [streamer, sErr] = client.telem.openStreamer(synnax::StreamerConfig{ + channels, + downsample_factor + }); + + // Sleep for 5 milliseconds to allow for the streamer to bootstrap. + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + + auto frame = synnax::Frame(1); + frame.add( + data.key, + synnax::Series(raw_data) + ); + ASSERT_TRUE(writer.write(std::move(frame))); + auto [res_frame, recErr] = streamer.read(); + ASSERT_FALSE(recErr) << recErr.message(); + + for (int i = 0; i < expected.size(); i++) + ASSERT_EQ(res_frame.series->at(0).values()[i], expected[i]); + + auto wcErr = writer.close(); + ASSERT_FALSE(cErr) << cErr.message(); + auto wsErr = streamer.close(); + ASSERT_FALSE(wsErr) << wsErr.message(); +} + +void test_downsample_string( + const std::vector& raw_data, + const std::vector& expected, + int32_t downsample_factor +) { + auto client = new_test_client(); + + // Create a virtual channel + synnax::Channel virtual_channel("virtual_string_channel", synnax::STRING, true); + auto err = client.channels.create(virtual_channel); + ASSERT_FALSE(err) << err.message(); + + auto now = synnax::TimeStamp::now(); + std::vector channels = {virtual_channel.key}; + auto [writer, wErr] = client.telem.openWriter(synnax::WriterConfig{ + channels, + now, + std::vector{synnax::AUTH_ABSOLUTE}, + synnax::ControlSubject{"test_writer"} + }); + ASSERT_FALSE(wErr) << wErr.message(); + + auto [streamer, sErr] = client.telem.openStreamer(synnax::StreamerConfig{ + channels, + downsample_factor + }); + ASSERT_FALSE(sErr) << sErr.message(); + + // Sleep for 5 milliseconds to allow for the streamer to bootstrap. + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + + auto frame = synnax::Frame(1); + frame.add(virtual_channel.key, synnax::Series(raw_data, synnax::STRING)); + ASSERT_TRUE(writer.write(std::move(frame))); + auto [res_frame, recErr] = streamer.read(); + ASSERT_FALSE(recErr) << recErr.message(); + + // Get the downsampled strings + std::vector received_strings = res_frame.series->at(0).strings(); + + ASSERT_EQ(received_strings.size(), expected.size()); + for (size_t i = 0; i < expected.size(); i++) + ASSERT_EQ(received_strings[i], expected[i]); + + auto wcErr = writer.close(); + ASSERT_FALSE(wcErr) << wcErr.message(); + auto wsErr = streamer.close(); + ASSERT_FALSE(wsErr) << wsErr.message(); +} + +TEST(FramerTests, TestStreamDownsampleString) { + std::vector data = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}; + + std::vector expected = {"a", "c", "e", "g", "i"}; + test_downsample_string(data, expected, 2); + +} \ No newline at end of file diff --git a/client/py/synnax/channel/payload.py b/client/py/synnax/channel/payload.py index bad60a7ab1..14012943d3 100644 --- a/client/py/synnax/channel/payload.py +++ b/client/py/synnax/channel/payload.py @@ -23,7 +23,6 @@ ChannelNames = list[str] ChannelParams = ChannelKeys | ChannelNames | ChannelKey | ChannelName - class ChannelPayload(Payload): """A payload container that represent the properties of a channel exchanged to and from the Synnax server. diff --git a/client/py/synnax/framer/adapter.py b/client/py/synnax/framer/adapter.py index d3f78ee79f..3c0f72795d 100644 --- a/client/py/synnax/framer/adapter.py +++ b/client/py/synnax/framer/adapter.py @@ -21,7 +21,6 @@ from synnax.framer.frame import Frame, CrudeFrame from synnax.telem.series import CrudeSeries, Series - class ReadFrameAdapter: __adapter: dict[ChannelKey, ChannelName] | None retriever: ChannelRetriever diff --git a/client/py/synnax/framer/client.py b/client/py/synnax/framer/client.py index 1f58a227a2..faa47c5028 100644 --- a/client/py/synnax/framer/client.py +++ b/client/py/synnax/framer/client.py @@ -256,24 +256,31 @@ def read( ) return series - def open_streamer(self, channels: ChannelParams) -> Streamer: + def open_streamer(self, channels: ChannelParams, downsample_factor: int = 1) -> Streamer: """Opens a new streamer on the given channels. The streamer will immediately being receiving frames of data from the given channels. :param channels: The channels to stream from. This can be a single channel name, a list of channel names, a single channel key, or a list of channel keys. + + :param downsample_factor: The downsample factor to use for the streamer. """ adapter = ReadFrameAdapter(self.__channels) adapter.update(channels) return Streamer( adapter=adapter, client=self.__stream_client, + downsample_factor=downsample_factor, ) - async def open_async_streamer(self, channels: ChannelParams) -> AsyncStreamer: + async def open_async_streamer(self, channels: ChannelParams, downsample_factor: int = 1) -> AsyncStreamer: adapter = ReadFrameAdapter(self.__channels) adapter.update(channels) - s = AsyncStreamer(adapter=adapter, client=self.__async_client) + s = AsyncStreamer( + adapter=adapter, + client=self.__async_client, + downsample_factor=downsample_factor, + ) await s._open() return s diff --git a/client/py/synnax/framer/streamer.py b/client/py/synnax/framer/streamer.py index e195a421d4..abe9beb042 100644 --- a/client/py/synnax/framer/streamer.py +++ b/client/py/synnax/framer/streamer.py @@ -27,7 +27,7 @@ class _Request(Payload): keys: ChannelKeys - + downsample_factor: int class _Response(Payload): frame: FramePayload @@ -63,13 +63,15 @@ def __init__( self, client: StreamClient, adapter: ReadFrameAdapter, + downsample_factor: int, ) -> None: self._stream = client.stream(_ENDPOINT, _Request, _Response) self._adapter = adapter + self._downsample_factor = downsample_factor self.__open() def __open(self): - self._stream.send(_Request(keys=self._adapter.keys)) + self._stream.send(_Request(keys=self._adapter.keys, downsample_factor=self._downsample_factor)) _, exc = self._stream.receive() if exc is not None: raise exc @@ -126,7 +128,7 @@ def update_channels(self, channels: ChannelParams): :raises NotFoundError: If any of the channels in the list are not found. """ self._adapter.update(channels) - self._stream.send(_Request(keys=self._adapter.keys)) + self._stream.send(_Request(keys=self._adapter.keys, downsample_factor=self._downsample_factor)) def close(self, timeout: float | int | TimeSpan | None = None): """Closes the streamer and frees all network resources. @@ -197,13 +199,22 @@ def __init__( self, client: AsyncStreamClient, adapter: ReadFrameAdapter, + downsample_factor: int, ) -> None: self._client = client self._adapter = adapter + self._downsample_factor = downsample_factor async def _open(self): - self._stream = await self._client.stream(_ENDPOINT, _Request, _Response) - await self._stream.send(_Request(keys=self._adapter.keys)) + self._stream = await self._client.stream( + _ENDPOINT, + _Request, + _Response + ) + await self._stream.send(_Request( + keys=self._adapter.keys, + downsample_factor=self._downsample_factor, + )) _, exc = await self._stream.receive() if exc is not None: raise exc diff --git a/client/py/tests/test_framer.py b/client/py/tests/test_framer.py index e643c6270b..4c66a69a62 100644 --- a/client/py/tests/test_framer.py +++ b/client/py/tests/test_framer.py @@ -437,18 +437,85 @@ def test_timeout_timespan(self, channel: sy.Channel, client: sy.Synnax): assert f is None assert abs(TimeSpan.since(start).seconds - 0.1) < 0.05 + def test_downsample(self, channel: sy.Channel, client: sy.Synnax): + """Should correctly stream data for a channel""" + with client.open_streamer(channel.key, 1) as s: + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + data = np.random.rand(10).astype(np.float64) + w.write(pd.DataFrame({channel.key: data})) + frame = s.read(timeout=1) + assert all(frame[channel.key] == data) + with client.open_streamer(channel.key, 2) as s: + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + data = [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0] + expect = [1.0,3.0,5.0,7.0,9.0] + w.write(pd.DataFrame({channel.key: data})) + frame = s.read(timeout=1) + assert all(frame[channel.key] == expect) + with client.open_streamer(channel.key, 10) as s: + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + data = [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0] + expect = [1.0] + w.write(pd.DataFrame({channel.key: data})) + frame = s.read(timeout=1) + assert all(frame[channel.key] == expect) + with client.open_streamer(channel.key, 20) as s: + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + data = [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0] + expect = [1.0] + w.write(pd.DataFrame({channel.key: data})) + frame = s.read(timeout=1) + assert all(frame[channel.key] == expect) + with client.open_streamer(channel.key, -1) as s: + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] + w.write(pd.DataFrame({channel.key: data})) + frame = s.read(timeout=1) + assert all(frame[channel.key] == data) + @pytest.mark.framer class TestAsyncStreamer: @pytest.mark.asyncio async def test_basic_stream(self, channel: sy.Channel, client: sy.Synnax): with client.open_writer(sy.TimeStamp.now(), channel.key) as w: - async with await client.open_async_streamer(channel.key) as s: + async with await client.open_async_streamer(channel.key,1) as s: time.sleep(0.1) data = np.random.rand(10).astype(np.float64) w.write(pd.DataFrame({channel.key: data})) frame = await s.read() assert all(frame[channel.key] == data) + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + async with await client.open_async_streamer(channel.key, 2) as s: + time.sleep(0.1) + data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] + expect = [1.0, 3.0, 5.0, 7.0, 9.0] + w.write(pd.DataFrame({channel.key: data})) + frame = await s.read() + assert all(frame[channel.key] == expect) + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + async with await client.open_async_streamer(channel.key, 10) as s: + time.sleep(0.1) + data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] + expect = [1.0] + w.write(pd.DataFrame({channel.key: data})) + frame = await s.read() + assert all(frame[channel.key] == expect) + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + async with await client.open_async_streamer(channel.key, 20) as s: + time.sleep(0.1) + data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] + expect = [1.0] + w.write(pd.DataFrame({channel.key: data})) + frame = await s.read() + assert all(frame[channel.key] == expect) + with client.open_writer(sy.TimeStamp.now(), channel.key) as w: + async with await client.open_async_streamer(channel.key, -1) as s: + time.sleep(0.1) + data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] + w.write(pd.DataFrame({channel.key: data})) + frame = await s.read() + assert all(frame[channel.key] == data) @pytest.mark.framer @@ -546,3 +613,5 @@ def test_delete_index_alone(self, client: sy.Synnax): TimeStamp(1 * TimeSpan.SECOND).range(TimeStamp(2 * TimeSpan.SECOND)) ), ) + + diff --git a/client/ts/src/framer/client.ts b/client/ts/src/framer/client.ts index 07814d007c..8e6267e4e7 100644 --- a/client/ts/src/framer/client.ts +++ b/client/ts/src/framer/client.ts @@ -99,7 +99,7 @@ export class Client { async openStreamer(config: StreamerConfig | Params): Promise { if (Array.isArray(config) || typeof config !== "object") - config = { channels: config as Params }; + config = { channels: config as Params, downsampleFactor: 1 }; return await Streamer._open(this.retriever, this.streamClient, config); } diff --git a/client/ts/src/framer/streamer.spec.ts b/client/ts/src/framer/streamer.spec.ts index 420ac92dbd..986c3ee45e 100644 --- a/client/ts/src/framer/streamer.spec.ts +++ b/client/ts/src/framer/streamer.spec.ts @@ -50,4 +50,52 @@ describe("Streamer", () => { it("should throw an error when the streamer is opened with a channel that does not exist", async () => { await expect(client.openStreamer([5678])).rejects.toThrow("not found"); }); + test("downsample factor of 1", async () => { + const ch = await newChannel(); + const streamer = await client.openStreamer({channels: ch.key, downsampleFactor: 1}); + await new Promise((resolve) => setTimeout(resolve, 100)); + const writer = await client.openWriter({ + start: TimeStamp.now(), + channels: ch.key, + }); + try { + await writer.write(ch.key, new Float64Array([1, 2, 3, 4, 5])); + } finally { + await writer.close(); + } + const d = await streamer.read(); + expect(Array.from(d.get(ch.key))).toEqual([1, 2, 3, 4, 5]); + }); +test("downsample factor of 2", async () => { + const ch = await newChannel(); + const streamer = await client.openStreamer({channels: ch.key, downsampleFactor: 2}); + await new Promise((resolve) => setTimeout(resolve, 100)); + const writer = await client.openWriter({ + start: TimeStamp.now(), + channels: ch.key, + }); + try { + await writer.write(ch.key, new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])); + } finally { + await writer.close(); + } + const d = await streamer.read(); + expect(Array.from(d.get(ch.key))).toEqual([1, 3, 5, 7, 9]); + }); +test("downsample factor of 10", async () => { + const ch = await newChannel(); + const streamer = await client.openStreamer({channels: ch.key, downsampleFactor: 10}); + await new Promise((resolve) => setTimeout(resolve, 100)); + const writer = await client.openWriter({ + start: TimeStamp.now(), + channels: ch.key, + }); + try { + await writer.write(ch.key, new Float64Array([1, 2, 3, 4, 5, 6,7,8,9,10])); + } finally { + await writer.close(); + } + const d = await streamer.read(); + expect(Array.from(d.get(ch.key))).toEqual([1]); + }); }); diff --git a/client/ts/src/framer/streamer.ts b/client/ts/src/framer/streamer.ts index 88f02eeb0e..1ad0bdb8d0 100644 --- a/client/ts/src/framer/streamer.ts +++ b/client/ts/src/framer/streamer.ts @@ -17,7 +17,7 @@ import { ReadFrameAdapter } from "@/framer/adapter"; import { Frame, frameZ } from "@/framer/frame"; import { StreamProxy } from "@/framer/streamProxy"; -const reqZ = z.object({ keys: z.number().array() }); +const reqZ = z.object({ keys: z.number().array() , downsampleFactor: z.number() }); const resZ = z.object({ frame: frameZ, @@ -28,11 +28,13 @@ const ENDPOINT = "/frame/stream"; export interface StreamerConfig { channels: Params; + downsampleFactor?: number; } export class Streamer implements AsyncIterator, AsyncIterable { private readonly stream: StreamProxy; private readonly adapter: ReadFrameAdapter; + private readonly downsampleFactor: number; private constructor( stream: Stream, @@ -40,6 +42,7 @@ export class Streamer implements AsyncIterator, AsyncIterable { ) { this.stream = new StreamProxy("Streamer", stream); this.adapter = adapter; + this.downsampleFactor = 1; } get keys(): Key[] { @@ -49,12 +52,12 @@ export class Streamer implements AsyncIterator, AsyncIterable { static async _open( retriever: Retriever, client: StreamClient, - { channels }: StreamerConfig, + { channels, downsampleFactor }: StreamerConfig, ): Promise { const adapter = await ReadFrameAdapter.open(retriever, channels); const stream = await client.stream(ENDPOINT, reqZ, resZ); const streamer = new Streamer(stream, adapter); - stream.send({ keys: adapter.keys }); + stream.send({ keys: adapter.keys, downsampleFactor: downsampleFactor ?? 1 }); const [, err] = await stream.receive(); if (err != null) throw err; return streamer; @@ -76,7 +79,7 @@ export class Streamer implements AsyncIterator, AsyncIterable { async update(channels: Params): Promise { await this.adapter.update(channels); - this.stream.send({ keys: this.adapter.keys }); + this.stream.send({ keys: this.adapter.keys, downsampleFactor: this.downsampleFactor }); } close(): void { diff --git a/docs/site/src/pages/reference/concepts/streams.mdx b/docs/site/src/pages/reference/concepts/streams.mdx index 0ed3e47324..6d9997fc23 100644 --- a/docs/site/src/pages/reference/concepts/streams.mdx +++ b/docs/site/src/pages/reference/concepts/streams.mdx @@ -8,6 +8,7 @@ prevURL: "/reference/concepts/writes" --- import { Divider } from "@synnaxlabs/pluto"; +import Table from "@/components/Table.astro"; import Code from "@/components/code/Code.astro"; export const components = { pre: Code }; @@ -38,6 +39,26 @@ To open a streamer, you'll need to provide a list of channels that you'd like to data from. The streamer will validate that the channels exists and are readable before starting the stream. +#### Optional Arguments + +There are also a few optional arguments we can provide when opening a streamer: + + + + + + + + + + + + {/* prettier-ignore */} + + + +
ArgumentDescription
Downsample Factor A positive integer that determines the reduction in the stream's original data rate. A value of n means only every nth sample is retained. Defaults to 1, meaning no downsampling.
+ ### Reading Data Once the streamer is open, you can read data from the stream using the `read` method. diff --git a/docs/site/src/pages/reference/python-client/stream-data.mdx b/docs/site/src/pages/reference/python-client/stream-data.mdx index 33ca28ec0e..3268b7a458 100644 --- a/docs/site/src/pages/reference/python-client/stream-data.mdx +++ b/docs/site/src/pages/reference/python-client/stream-data.mdx @@ -61,6 +61,17 @@ if frame is None: print("Timed out waiting for a frame") ``` +### Downsampling Frames + +If you are interested in streaming data at a lower rate than what is being written to the server, you can use the optional `downsample` parameter to specify the number of frames to skip before returning the next frame: + +```python +# setting the downsample factor to n means every nth sample will be retained +# e.g. for a downsample of 2, if [0.13, 0.12, 0.14, 0.13] is written, +# a streamer.read() will return [0.13, 0.14] +stream = client.open_streamer(["temperature", "pressure"], 2) +``` + ### Handling Partial Frames When reading frames from a streamer, it's important to note that a frame may not diff --git a/docs/site/src/pages/reference/typescript-client/stream-data.mdx b/docs/site/src/pages/reference/typescript-client/stream-data.mdx index 311927fd79..b7f199c005 100644 --- a/docs/site/src/pages/reference/typescript-client/stream-data.mdx +++ b/docs/site/src/pages/reference/typescript-client/stream-data.mdx @@ -46,6 +46,19 @@ frame containing data only for the second channel. For more details on how to work with the returned frames, see the [Series and Frames](series-and-frames) page. +x +### Downsampling Frames + +If you are interested in streaming data at a lower rate than is being written to the server, you can use the optional `downsample` parameter to specify the number of frames to skip before returning the next frame: + +```typescript +// setting the downsample factor to n means every nth sample will be retained +// e.g. for a downsample factor of 2, if [0.13, 0.12, 0.14, 0.13] is written, +// a streamer.read() will return [0.13, 0.14] + +const streamer = await client.openStreamer(["temperature1", "temperature2"],2); +``` + ### Handling Partial Frames When reading frames from a streamer, it's important to note that a frame may not diff --git a/synnax/cmd/start.go b/synnax/cmd/start.go index 0a134e2f06..17f9bfca9e 100644 --- a/synnax/cmd/start.go +++ b/synnax/cmd/start.go @@ -13,6 +13,14 @@ import ( "bufio" "context" "encoding/base64" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/auth/token" + "github.com/synnaxlabs/synnax/pkg/service/framer" + "github.com/synnaxlabs/synnax/pkg/service/label" + "github.com/synnaxlabs/synnax/pkg/service/user" "os" "os/signal" "time" @@ -24,28 +32,21 @@ import ( "github.com/synnaxlabs/alamos" "github.com/synnaxlabs/freighter/fgrpc" "github.com/synnaxlabs/freighter/fhttp" - "github.com/synnaxlabs/synnax/pkg/access" - "github.com/synnaxlabs/synnax/pkg/access/rbac" "github.com/synnaxlabs/synnax/pkg/api" grpcapi "github.com/synnaxlabs/synnax/pkg/api/grpc" httpapi "github.com/synnaxlabs/synnax/pkg/api/http" - "github.com/synnaxlabs/synnax/pkg/auth" - "github.com/synnaxlabs/synnax/pkg/auth/password" - "github.com/synnaxlabs/synnax/pkg/auth/token" "github.com/synnaxlabs/synnax/pkg/distribution" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/hardware" - "github.com/synnaxlabs/synnax/pkg/hardware/embedded" - "github.com/synnaxlabs/synnax/pkg/label" - "github.com/synnaxlabs/synnax/pkg/ranger" "github.com/synnaxlabs/synnax/pkg/security" "github.com/synnaxlabs/synnax/pkg/server" + "github.com/synnaxlabs/synnax/pkg/service/hardware" + "github.com/synnaxlabs/synnax/pkg/service/hardware/embedded" + "github.com/synnaxlabs/synnax/pkg/service/ranger" + "github.com/synnaxlabs/synnax/pkg/service/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace/lineplot" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" "github.com/synnaxlabs/synnax/pkg/storage" - "github.com/synnaxlabs/synnax/pkg/user" "github.com/synnaxlabs/synnax/pkg/version" - "github.com/synnaxlabs/synnax/pkg/workspace" - "github.com/synnaxlabs/synnax/pkg/workspace/lineplot" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" "github.com/synnaxlabs/x/address" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/errors" @@ -207,6 +208,7 @@ func start(cmd *cobra.Command) { Signals: dist.Signals, Channel: dist.Channel, }) + frameSvc, err := framer.NewService(dist.Framer) if err != nil { return err } @@ -234,7 +236,7 @@ func start(cmd *cobra.Command) { LinePlot: linePlotSvc, Insecure: config.Bool(insecure), Channel: dist.Channel, - Framer: dist.Framer, + Framer: frameSvc, Storage: dist.Storage, User: userSvc, Token: tokenSvc, diff --git a/synnax/pkg/api/access.go b/synnax/pkg/api/access.go index 4ce713f7cc..d565dd8e36 100644 --- a/synnax/pkg/api/access.go +++ b/synnax/pkg/api/access.go @@ -14,9 +14,9 @@ import ( "go/types" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/access" - "github.com/synnaxlabs/synnax/pkg/access/rbac" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/api.go b/synnax/pkg/api/api.go index a75602b76a..a9b899c641 100644 --- a/synnax/pkg/api/api.go +++ b/synnax/pkg/api/api.go @@ -20,23 +20,23 @@ import ( "github.com/synnaxlabs/alamos" "github.com/synnaxlabs/freighter" "github.com/synnaxlabs/freighter/falamos" - "github.com/synnaxlabs/synnax/pkg/access" - "github.com/synnaxlabs/synnax/pkg/access/rbac" - "github.com/synnaxlabs/synnax/pkg/auth" - "github.com/synnaxlabs/synnax/pkg/auth/token" "github.com/synnaxlabs/synnax/pkg/distribution/channel" dcore "github.com/synnaxlabs/synnax/pkg/distribution/core" - "github.com/synnaxlabs/synnax/pkg/distribution/framer" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/hardware" - "github.com/synnaxlabs/synnax/pkg/label" - "github.com/synnaxlabs/synnax/pkg/ranger" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth/token" + "github.com/synnaxlabs/synnax/pkg/service/framer" + "github.com/synnaxlabs/synnax/pkg/service/hardware" + "github.com/synnaxlabs/synnax/pkg/service/label" + "github.com/synnaxlabs/synnax/pkg/service/ranger" + "github.com/synnaxlabs/synnax/pkg/service/user" + "github.com/synnaxlabs/synnax/pkg/service/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace/lineplot" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" "github.com/synnaxlabs/synnax/pkg/storage" - "github.com/synnaxlabs/synnax/pkg/user" - "github.com/synnaxlabs/synnax/pkg/workspace" - "github.com/synnaxlabs/synnax/pkg/workspace/lineplot" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/override" "github.com/synnaxlabs/x/validate" diff --git a/synnax/pkg/api/auth.go b/synnax/pkg/api/auth.go index f268e449a0..0fbd024d12 100644 --- a/synnax/pkg/api/auth.go +++ b/synnax/pkg/api/auth.go @@ -13,9 +13,9 @@ import ( "context" "go/types" - "github.com/synnaxlabs/synnax/pkg/auth" - "github.com/synnaxlabs/synnax/pkg/auth/password" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/user" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/channel.go b/synnax/pkg/api/channel.go index 52c1f3ebe3..5b2f98e10d 100644 --- a/synnax/pkg/api/channel.go +++ b/synnax/pkg/api/channel.go @@ -11,16 +11,16 @@ package api import ( "context" + "github.com/synnaxlabs/synnax/pkg/distribution/ontology" + "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" + "github.com/synnaxlabs/synnax/pkg/service/access" "go/types" "github.com/google/uuid" "github.com/samber/lo" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution" "github.com/synnaxlabs/synnax/pkg/distribution/channel" - "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/ranger" + "github.com/synnaxlabs/synnax/pkg/service/ranger" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/query" diff --git a/synnax/pkg/api/framer.go b/synnax/pkg/api/framer.go index 7783ba1dd6..5eb567fd44 100644 --- a/synnax/pkg/api/framer.go +++ b/synnax/pkg/api/framer.go @@ -16,12 +16,13 @@ import ( "github.com/synnaxlabs/alamos" "github.com/synnaxlabs/freighter" "github.com/synnaxlabs/freighter/freightfluence" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/channel" "github.com/synnaxlabs/synnax/pkg/distribution/framer" "github.com/synnaxlabs/synnax/pkg/distribution/framer/iterator" "github.com/synnaxlabs/synnax/pkg/distribution/framer/writer" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" + "github.com/synnaxlabs/synnax/pkg/service/access" + framesvc "github.com/synnaxlabs/synnax/pkg/service/framer" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/confluence" "github.com/synnaxlabs/x/confluence/plumber" @@ -39,7 +40,7 @@ type FrameService struct { authProvider dbProvider accessProvider - Internal *framer.Service + Internal *framesvc.Service } func NewFrameService(p Provider) *FrameService { @@ -198,7 +199,7 @@ func (s *FrameService) openStreamer( }); err != nil { return nil, err } - reader, err := s.Internal.NewStreamer(ctx, framer.StreamerConfig{Keys: req.Keys}) + reader, err := s.Internal.NewStreamer(ctx, framer.StreamerConfig{Keys: req.Keys, DownsampleFactor: req.DownsampleFactor}) if err != nil { return nil, err } diff --git a/synnax/pkg/api/grpc/auth.go b/synnax/pkg/api/grpc/auth.go index 758b5647c6..a4617865af 100644 --- a/synnax/pkg/api/grpc/auth.go +++ b/synnax/pkg/api/grpc/auth.go @@ -16,9 +16,9 @@ import ( "github.com/synnaxlabs/freighter/fgrpc" "github.com/synnaxlabs/synnax/pkg/api" gapi "github.com/synnaxlabs/synnax/pkg/api/grpc/v1" - "github.com/synnaxlabs/synnax/pkg/auth" - "github.com/synnaxlabs/synnax/pkg/auth/password" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/user" ) type ( diff --git a/synnax/pkg/api/grpc/framer.go b/synnax/pkg/api/grpc/framer.go index e1ddfbe488..ca081199d4 100644 --- a/synnax/pkg/api/grpc/framer.go +++ b/synnax/pkg/api/grpc/framer.go @@ -235,14 +235,20 @@ func (t frameStreamerRequestTranslator) Forward( ctx context.Context, msg api.FrameStreamerRequest, ) (*gapi.FrameStreamerRequest, error) { - return &gapi.FrameStreamerRequest{Keys: translateChannelKeysForward(msg.Keys)}, nil + return &gapi.FrameStreamerRequest{ + Keys: translateChannelKeysForward(msg.Keys), + DownsampleFactor: int32(msg.DownsampleFactor), + }, nil } func (t frameStreamerRequestTranslator) Backward( ctx context.Context, msg *gapi.FrameStreamerRequest, ) (api.FrameStreamerRequest, error) { - return api.FrameStreamerRequest{Keys: translateChannelKeysBackward(msg.Keys)}, nil + return api.FrameStreamerRequest{ + Keys: translateChannelKeysBackward(msg.Keys), + DownsampleFactor: int(msg.DownsampleFactor), + }, nil } func (t frameStreamerResponseTranslator) Forward( diff --git a/synnax/pkg/api/grpc/hardware.go b/synnax/pkg/api/grpc/hardware.go index f29670877d..99bd381b3c 100644 --- a/synnax/pkg/api/grpc/hardware.go +++ b/synnax/pkg/api/grpc/hardware.go @@ -16,8 +16,8 @@ import ( "github.com/synnaxlabs/freighter/fgrpc" "github.com/synnaxlabs/synnax/pkg/api" gapi "github.com/synnaxlabs/synnax/pkg/api/grpc/v1" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" - "github.com/synnaxlabs/synnax/pkg/hardware/task" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/task" "github.com/synnaxlabs/x/unsafe" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/synnax/pkg/api/grpc/v1/framer.pb.go b/synnax/pkg/api/grpc/v1/framer.pb.go index 9dc4fc1a97..3963f34a70 100644 --- a/synnax/pkg/api/grpc/v1/framer.pb.go +++ b/synnax/pkg/api/grpc/v1/framer.pb.go @@ -519,7 +519,8 @@ type FrameStreamerRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Keys []uint32 `protobuf:"varint,1,rep,packed,name=keys,proto3" json:"keys,omitempty"` + Keys []uint32 `protobuf:"varint,1,rep,packed,name=keys,proto3" json:"keys,omitempty"` + DownsampleFactor int32 `protobuf:"varint,2,opt,name=downsample_factor,json=downsampleFactor,proto3" json:"downsample_factor,omitempty"` } func (x *FrameStreamerRequest) Reset() { @@ -561,6 +562,13 @@ func (x *FrameStreamerRequest) GetKeys() []uint32 { return nil } +func (x *FrameStreamerRequest) GetDownsampleFactor() int32 { + if x != nil { + return x.DownsampleFactor + } + return 0 +} + type FrameStreamerResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -762,55 +770,58 @@ var file_synnax_pkg_api_grpc_v1_framer_proto_rawDesc = []byte{ 0x72, 0x12, 0x27, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x50, 0x42, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, - 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x2a, 0x0a, 0x14, + 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x57, 0x0a, 0x14, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0d, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x22, 0x65, 0x0a, 0x15, 0x46, 0x72, 0x61, 0x6d, - 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x23, 0x0a, 0x05, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, - 0x05, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x50, - 0x42, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, - 0x6a, 0x0a, 0x12, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0d, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6d, - 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x12, - 0x2a, 0x0a, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x12, 0x2e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x2e, 0x50, 0x42, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x61, - 0x6e, 0x67, 0x65, 0x52, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x32, 0x61, 0x0a, 0x14, 0x46, - 0x72, 0x61, 0x6d, 0x65, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x49, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, - 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x5b, - 0x0a, 0x12, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x57, 0x72, 0x69, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1a, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x57, 0x72, 0x69, 0x74, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x57, 0x72, 0x69, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x61, 0x0a, 0x14, 0x46, - 0x72, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x49, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x52, - 0x0a, 0x12, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x3c, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1a, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x22, 0x00, 0x42, 0x80, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x42, 0x0b, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x79, 0x6e, - 0x6e, 0x61, 0x78, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x73, 0x79, 0x6e, 0x6e, 0x61, 0x78, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0xa2, 0x02, - 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, - 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x41, 0x70, - 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x28, 0x0d, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x6f, 0x77, 0x6e, + 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x46, + 0x61, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x65, 0x0a, 0x15, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, + 0x0a, 0x05, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x52, 0x05, 0x66, 0x72, + 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x50, 0x42, 0x50, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x6a, 0x0a, 0x12, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0d, + 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x06, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, + 0x65, 0x6c, 0x65, 0x6d, 0x2e, 0x50, 0x42, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x61, 0x6e, 0x67, 0x65, + 0x52, 0x06, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x32, 0x61, 0x0a, 0x14, 0x46, 0x72, 0x61, 0x6d, + 0x65, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x49, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x49, 0x74, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x5b, 0x0a, 0x12, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x57, 0x72, 0x69, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x45, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x57, 0x72, 0x69, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x57, 0x72, 0x69, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x61, 0x0a, 0x14, 0x46, 0x72, 0x61, 0x6d, + 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x49, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x52, 0x0a, 0x12, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x3c, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, + 0x80, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x0b, + 0x46, 0x72, 0x61, 0x6d, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x79, 0x6e, 0x6e, 0x61, 0x78, + 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x73, 0x79, 0x6e, 0x6e, 0x61, 0x78, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, + 0x58, 0xaa, 0x02, 0x06, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, 0x41, 0x70, 0x69, + 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x41, 0x70, 0x69, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/synnax/pkg/api/grpc/v1/framer.proto b/synnax/pkg/api/grpc/v1/framer.proto index 37084d6ab4..0bd28a659b 100644 --- a/synnax/pkg/api/grpc/v1/framer.proto +++ b/synnax/pkg/api/grpc/v1/framer.proto @@ -73,6 +73,7 @@ message FrameWriterResponse { message FrameStreamerRequest { repeated uint32 keys = 1; + int32 downsample_factor = 2; } message FrameStreamerResponse { diff --git a/synnax/pkg/api/hardware.go b/synnax/pkg/api/hardware.go index c5f44a8a66..7bead06d4a 100644 --- a/synnax/pkg/api/hardware.go +++ b/synnax/pkg/api/hardware.go @@ -13,14 +13,14 @@ package api import ( "context" + access "github.com/synnaxlabs/synnax/pkg/service/access" "go/types" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/hardware" - "github.com/synnaxlabs/synnax/pkg/hardware/device" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" - "github.com/synnaxlabs/synnax/pkg/hardware/task" + "github.com/synnaxlabs/synnax/pkg/service/hardware" + "github.com/synnaxlabs/synnax/pkg/service/hardware/device" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/task" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/label.go b/synnax/pkg/api/label.go index a7cfaf7bd4..7573b22652 100644 --- a/synnax/pkg/api/label.go +++ b/synnax/pkg/api/label.go @@ -16,9 +16,9 @@ import ( "go/types" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/label" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/label" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/lineplot.go b/synnax/pkg/api/lineplot.go index 42a6b26b11..ec455226f6 100644 --- a/synnax/pkg/api/lineplot.go +++ b/synnax/pkg/api/lineplot.go @@ -14,9 +14,9 @@ import ( "go/types" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/workspace/lineplot" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/workspace/lineplot" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/mock/mock.go b/synnax/pkg/api/mock/mock.go index 1931ad11e8..e55195baa6 100644 --- a/synnax/pkg/api/mock/mock.go +++ b/synnax/pkg/api/mock/mock.go @@ -13,18 +13,18 @@ import ( "context" "crypto/rand" "crypto/rsa" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth/token" + "github.com/synnaxlabs/synnax/pkg/service/user" + . "github.com/synnaxlabs/x/testutil" "time" - "github.com/synnaxlabs/synnax/pkg/access" - "github.com/synnaxlabs/synnax/pkg/access/rbac" "github.com/synnaxlabs/synnax/pkg/api" - "github.com/synnaxlabs/synnax/pkg/auth" - "github.com/synnaxlabs/synnax/pkg/auth/token" "github.com/synnaxlabs/synnax/pkg/distribution" "github.com/synnaxlabs/synnax/pkg/distribution/mock" securitymock "github.com/synnaxlabs/synnax/pkg/security/mock" - "github.com/synnaxlabs/synnax/pkg/user" - . "github.com/synnaxlabs/x/testutil" ) type Builder struct { @@ -43,7 +43,6 @@ func (b *Builder) NewConfig(ctx context.Context) api.Config { } return api.Config{ Channel: dist.Channel, - Framer: dist.Framer, Ontology: dist.Ontology, Storage: dist.Storage, User: MustSucceed(user.NewService(ctx, user.Config{DB: dist.Storage.Gorpify(), Ontology: dist.Ontology, Group: dist.Group})), diff --git a/synnax/pkg/api/ontology.go b/synnax/pkg/api/ontology.go index 091b433b65..f91a70e0a3 100644 --- a/synnax/pkg/api/ontology.go +++ b/synnax/pkg/api/ontology.go @@ -14,11 +14,11 @@ import ( "go/types" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/schema" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/search" + "github.com/synnaxlabs/synnax/pkg/service/access" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/provider.go b/synnax/pkg/api/provider.go index de4ae10e62..32b81944c8 100644 --- a/synnax/pkg/api/provider.go +++ b/synnax/pkg/api/provider.go @@ -10,12 +10,12 @@ package api import ( - "github.com/synnaxlabs/synnax/pkg/access/rbac" - "github.com/synnaxlabs/synnax/pkg/auth" - "github.com/synnaxlabs/synnax/pkg/auth/token" dcore "github.com/synnaxlabs/synnax/pkg/distribution/core" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth/token" + "github.com/synnaxlabs/synnax/pkg/service/user" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/ranger.go b/synnax/pkg/api/ranger.go index 862a580313..3c61d61619 100644 --- a/synnax/pkg/api/ranger.go +++ b/synnax/pkg/api/ranger.go @@ -11,17 +11,17 @@ package api import ( "context" - "go/types" - - "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/channel" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/ranger" + "github.com/synnaxlabs/synnax/pkg/service/access" "github.com/synnaxlabs/x/errors" - "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/query" "github.com/synnaxlabs/x/telem" + "go/types" + + "github.com/google/uuid" + "github.com/synnaxlabs/synnax/pkg/service/ranger" + "github.com/synnaxlabs/x/gorp" ) type ( diff --git a/synnax/pkg/api/schematic.go b/synnax/pkg/api/schematic.go index 35bb47ca83..29e2478d24 100644 --- a/synnax/pkg/api/schematic.go +++ b/synnax/pkg/api/schematic.go @@ -14,9 +14,9 @@ import ( "go/types" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/api/token_middleware.go b/synnax/pkg/api/token_middleware.go index 8e7c0093ed..3059d77b21 100644 --- a/synnax/pkg/api/token_middleware.go +++ b/synnax/pkg/api/token_middleware.go @@ -11,17 +11,17 @@ package api import ( "context" + "github.com/google/uuid" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth/token" + "github.com/synnaxlabs/synnax/pkg/service/user" + "go.uber.org/zap" "strings" "github.com/gofiber/fiber/v2" - "github.com/google/uuid" "github.com/synnaxlabs/freighter" - "github.com/synnaxlabs/synnax/pkg/auth" - "github.com/synnaxlabs/synnax/pkg/auth/token" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/user" "github.com/synnaxlabs/x/errors" - "go.uber.org/zap" ) const tokenRefreshHeader = "Refresh-Token" diff --git a/synnax/pkg/api/user.go b/synnax/pkg/api/user.go index eaca0ad4b4..2223fcd3db 100644 --- a/synnax/pkg/api/user.go +++ b/synnax/pkg/api/user.go @@ -12,17 +12,16 @@ package api import ( "context" "errors" - "go/types" - "github.com/google/uuid" "github.com/samber/lo" - "github.com/synnaxlabs/synnax/pkg/access" - "github.com/synnaxlabs/synnax/pkg/access/rbac" - "github.com/synnaxlabs/synnax/pkg/auth" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/user" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/query" + "go/types" ) // UserService is the core authentication service for the Synnax API. diff --git a/synnax/pkg/api/workspace.go b/synnax/pkg/api/workspace.go index aed0ce9884..8844a09c93 100644 --- a/synnax/pkg/api/workspace.go +++ b/synnax/pkg/api/workspace.go @@ -14,10 +14,10 @@ import ( "go/types" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/user" - "github.com/synnaxlabs/synnax/pkg/workspace" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/user" + "github.com/synnaxlabs/synnax/pkg/service/workspace" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/distribution/framer/relay/streamer.go b/synnax/pkg/distribution/framer/relay/streamer.go index 575811f8dc..ba73096568 100644 --- a/synnax/pkg/distribution/framer/relay/streamer.go +++ b/synnax/pkg/distribution/framer/relay/streamer.go @@ -40,7 +40,12 @@ func (r *Relay) NewStreamer(ctx context.Context, cfg StreamerConfig) (Streamer, WhereKeys(keys...).Exec(ctx, nil); err != nil { return nil, err } - return &streamer{keys: keys, addr: address.Rand(), demands: r.demands, relay: r}, nil + return &streamer{ + keys: keys, + addr: address.Rand(), + demands: r.demands, + relay: r, + }, nil } // Flow implements confluence.Flow. diff --git a/synnax/pkg/distribution/framer/streamer.go b/synnax/pkg/distribution/framer/streamer.go index 13df125d09..d35d8f8da9 100644 --- a/synnax/pkg/distribution/framer/streamer.go +++ b/synnax/pkg/distribution/framer/streamer.go @@ -11,6 +11,7 @@ package framer import ( "context" + "github.com/samber/lo" "github.com/synnaxlabs/synnax/pkg/distribution/channel" "github.com/synnaxlabs/synnax/pkg/distribution/framer/core" @@ -127,7 +128,8 @@ func (l *streamer) Flow(sCtx signal.Context, opts ...confluence.Option) { } type StreamerConfig struct { - Keys channel.Keys `json:"keys" msgpack:"keys"` + Keys channel.Keys `json:"keys" msgpack:"keys"` + DownsampleFactor int `json:"downsample_factor" msgpack:"downsample_factor"` } type StreamerRequest = StreamerConfig diff --git a/synnax/pkg/distribution/ontology/writer_test.go b/synnax/pkg/distribution/ontology/writer_test.go index 3759baa6e7..7875ddd87b 100644 --- a/synnax/pkg/distribution/ontology/writer_test.go +++ b/synnax/pkg/distribution/ontology/writer_test.go @@ -13,7 +13,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/label" + "github.com/synnaxlabs/synnax/pkg/service/label" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/query" . "github.com/synnaxlabs/x/testutil" diff --git a/synnax/pkg/access/action.go b/synnax/pkg/service/access/action.go similarity index 100% rename from synnax/pkg/access/action.go rename to synnax/pkg/service/access/action.go diff --git a/synnax/pkg/access/allow_all.go b/synnax/pkg/service/access/allow_all.go similarity index 100% rename from synnax/pkg/access/allow_all.go rename to synnax/pkg/service/access/allow_all.go diff --git a/synnax/pkg/access/enforcer.go b/synnax/pkg/service/access/enforcer.go similarity index 100% rename from synnax/pkg/access/enforcer.go rename to synnax/pkg/service/access/enforcer.go diff --git a/synnax/pkg/access/errors.go b/synnax/pkg/service/access/errors.go similarity index 90% rename from synnax/pkg/access/errors.go rename to synnax/pkg/service/access/errors.go index fe31bef46b..400e390e45 100644 --- a/synnax/pkg/access/errors.go +++ b/synnax/pkg/service/access/errors.go @@ -10,7 +10,7 @@ package access import ( - "github.com/synnaxlabs/synnax/pkg/auth/base" + "github.com/synnaxlabs/synnax/pkg/service/auth/base" "github.com/synnaxlabs/x/errors" ) diff --git a/synnax/pkg/access/rbac/enforce.go b/synnax/pkg/service/access/rbac/enforce.go similarity index 94% rename from synnax/pkg/access/rbac/enforce.go rename to synnax/pkg/service/access/rbac/enforce.go index eee2e6770e..5816489fb7 100644 --- a/synnax/pkg/access/rbac/enforce.go +++ b/synnax/pkg/service/access/rbac/enforce.go @@ -11,8 +11,7 @@ package rbac import ( "context" - - "github.com/synnaxlabs/synnax/pkg/access" + "github.com/synnaxlabs/synnax/pkg/service/access" ) var _ access.Enforcer = (*Service)(nil) diff --git a/synnax/pkg/access/rbac/enforce_test.go b/synnax/pkg/service/access/rbac/enforce_test.go similarity index 97% rename from synnax/pkg/access/rbac/enforce_test.go rename to synnax/pkg/service/access/rbac/enforce_test.go index 94f65fd3f6..a574c8e9b0 100644 --- a/synnax/pkg/access/rbac/enforce_test.go +++ b/synnax/pkg/service/access/rbac/enforce_test.go @@ -13,10 +13,10 @@ import ( "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/access" - "github.com/synnaxlabs/synnax/pkg/access/rbac" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/user" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" . "github.com/synnaxlabs/x/testutil" diff --git a/synnax/pkg/access/rbac/ontology.go b/synnax/pkg/service/access/rbac/ontology.go similarity index 100% rename from synnax/pkg/access/rbac/ontology.go rename to synnax/pkg/service/access/rbac/ontology.go diff --git a/synnax/pkg/access/rbac/policy.go b/synnax/pkg/service/access/rbac/policy.go similarity index 98% rename from synnax/pkg/access/rbac/policy.go rename to synnax/pkg/service/access/rbac/policy.go index 51f4f83bc4..10aab241ee 100644 --- a/synnax/pkg/access/rbac/policy.go +++ b/synnax/pkg/service/access/rbac/policy.go @@ -12,8 +12,8 @@ package rbac import ( "github.com/google/uuid" "github.com/samber/lo" - "github.com/synnaxlabs/synnax/pkg/access" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" + "github.com/synnaxlabs/synnax/pkg/service/access" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/access/rbac/rbac_suite_test.go b/synnax/pkg/service/access/rbac/rbac_suite_test.go similarity index 85% rename from synnax/pkg/access/rbac/rbac_suite_test.go rename to synnax/pkg/service/access/rbac/rbac_suite_test.go index 329a5da214..8cfdd05e35 100644 --- a/synnax/pkg/access/rbac/rbac_suite_test.go +++ b/synnax/pkg/service/access/rbac/rbac_suite_test.go @@ -16,10 +16,10 @@ import ( "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/access" - "github.com/synnaxlabs/synnax/pkg/access/rbac" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/access" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/user" ) var ( diff --git a/synnax/pkg/access/rbac/retriever.go b/synnax/pkg/service/access/rbac/retriever.go similarity index 100% rename from synnax/pkg/access/rbac/retriever.go rename to synnax/pkg/service/access/rbac/retriever.go diff --git a/synnax/pkg/access/rbac/retriever_test.go b/synnax/pkg/service/access/rbac/retriever_test.go similarity index 96% rename from synnax/pkg/access/rbac/retriever_test.go rename to synnax/pkg/service/access/rbac/retriever_test.go index 9f2c56308f..0c0a074e56 100644 --- a/synnax/pkg/access/rbac/retriever_test.go +++ b/synnax/pkg/service/access/rbac/retriever_test.go @@ -12,7 +12,7 @@ package rbac_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" . "github.com/synnaxlabs/x/testutil" diff --git a/synnax/pkg/access/rbac/service.go b/synnax/pkg/service/access/rbac/service.go similarity index 100% rename from synnax/pkg/access/rbac/service.go rename to synnax/pkg/service/access/rbac/service.go diff --git a/synnax/pkg/access/rbac/writer.go b/synnax/pkg/service/access/rbac/writer.go similarity index 100% rename from synnax/pkg/access/rbac/writer.go rename to synnax/pkg/service/access/rbac/writer.go diff --git a/synnax/pkg/access/rbac/writer_test.go b/synnax/pkg/service/access/rbac/writer_test.go similarity index 96% rename from synnax/pkg/access/rbac/writer_test.go rename to synnax/pkg/service/access/rbac/writer_test.go index 5979b2b626..5bbed7b61d 100644 --- a/synnax/pkg/access/rbac/writer_test.go +++ b/synnax/pkg/service/access/rbac/writer_test.go @@ -12,7 +12,7 @@ package rbac_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/access/rbac" + "github.com/synnaxlabs/synnax/pkg/service/access/rbac" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" "github.com/synnaxlabs/x/query" diff --git a/synnax/pkg/auth/auth.go b/synnax/pkg/service/auth/auth.go similarity index 97% rename from synnax/pkg/auth/auth.go rename to synnax/pkg/service/auth/auth.go index 923d4e5f6d..5376a93a4f 100644 --- a/synnax/pkg/auth/auth.go +++ b/synnax/pkg/service/auth/auth.go @@ -11,8 +11,7 @@ package auth import ( "context" - - "github.com/synnaxlabs/synnax/pkg/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/auth/auth_suite_test.go b/synnax/pkg/service/auth/auth_suite_test.go similarity index 100% rename from synnax/pkg/auth/auth_suite_test.go rename to synnax/pkg/service/auth/auth_suite_test.go diff --git a/synnax/pkg/auth/auth_test.go b/synnax/pkg/service/auth/auth_test.go similarity index 99% rename from synnax/pkg/auth/auth_test.go rename to synnax/pkg/service/auth/auth_test.go index c815d9261c..2869e27167 100644 --- a/synnax/pkg/auth/auth_test.go +++ b/synnax/pkg/service/auth/auth_test.go @@ -12,7 +12,7 @@ package auth_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/auth" + "github.com/synnaxlabs/synnax/pkg/service/auth" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" diff --git a/synnax/pkg/auth/base/error.go b/synnax/pkg/service/auth/base/error.go similarity index 100% rename from synnax/pkg/auth/base/error.go rename to synnax/pkg/service/auth/base/error.go diff --git a/synnax/pkg/auth/credentials.go b/synnax/pkg/service/auth/credentials.go similarity index 96% rename from synnax/pkg/auth/credentials.go rename to synnax/pkg/service/auth/credentials.go index 49a4a31624..e93c432702 100644 --- a/synnax/pkg/auth/credentials.go +++ b/synnax/pkg/service/auth/credentials.go @@ -10,7 +10,7 @@ package auth import ( - "github.com/synnaxlabs/synnax/pkg/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" "github.com/synnaxlabs/x/validate" ) diff --git a/synnax/pkg/auth/errors.go b/synnax/pkg/service/auth/errors.go similarity index 94% rename from synnax/pkg/auth/errors.go rename to synnax/pkg/service/auth/errors.go index 1270c8bcc1..d4e3cd91f5 100644 --- a/synnax/pkg/auth/errors.go +++ b/synnax/pkg/service/auth/errors.go @@ -11,10 +11,10 @@ package auth import ( "context" + "github.com/synnaxlabs/synnax/pkg/service/auth/base" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" "strings" - "github.com/synnaxlabs/synnax/pkg/auth/base" - "github.com/synnaxlabs/synnax/pkg/auth/password" "github.com/synnaxlabs/x/errors" ) diff --git a/synnax/pkg/auth/kv.go b/synnax/pkg/service/auth/kv.go similarity index 98% rename from synnax/pkg/auth/kv.go rename to synnax/pkg/service/auth/kv.go index f4044e259a..428eed07db 100644 --- a/synnax/pkg/auth/kv.go +++ b/synnax/pkg/service/auth/kv.go @@ -12,8 +12,7 @@ package auth import ( "context" "fmt" - - "github.com/synnaxlabs/synnax/pkg/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/query" diff --git a/synnax/pkg/auth/multi.go b/synnax/pkg/service/auth/multi.go similarity index 98% rename from synnax/pkg/auth/multi.go rename to synnax/pkg/service/auth/multi.go index 8f4a4cf0b1..1f2b21de72 100644 --- a/synnax/pkg/auth/multi.go +++ b/synnax/pkg/service/auth/multi.go @@ -11,8 +11,7 @@ package auth import ( "context" - - "github.com/synnaxlabs/synnax/pkg/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/auth/password/hasher.go b/synnax/pkg/service/auth/password/hasher.go similarity index 100% rename from synnax/pkg/auth/password/hasher.go rename to synnax/pkg/service/auth/password/hasher.go diff --git a/synnax/pkg/auth/password/password.go b/synnax/pkg/service/auth/password/password.go similarity index 96% rename from synnax/pkg/auth/password/password.go rename to synnax/pkg/service/auth/password/password.go index 240d70574b..bd1604332e 100644 --- a/synnax/pkg/auth/password/password.go +++ b/synnax/pkg/service/auth/password/password.go @@ -10,7 +10,7 @@ package password import ( - "github.com/synnaxlabs/synnax/pkg/auth/base" + "github.com/synnaxlabs/synnax/pkg/service/auth/base" "github.com/synnaxlabs/x/errors" ) diff --git a/synnax/pkg/auth/password/password_suite_test.go b/synnax/pkg/service/auth/password/password_suite_test.go similarity index 100% rename from synnax/pkg/auth/password/password_suite_test.go rename to synnax/pkg/service/auth/password/password_suite_test.go diff --git a/synnax/pkg/auth/password/password_test.go b/synnax/pkg/service/auth/password/password_test.go similarity index 95% rename from synnax/pkg/auth/password/password_test.go rename to synnax/pkg/service/auth/password/password_test.go index d62d03edea..6cc72bae3f 100644 --- a/synnax/pkg/auth/password/password_test.go +++ b/synnax/pkg/service/auth/password/password_test.go @@ -12,7 +12,7 @@ package password_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/auth/password" + "github.com/synnaxlabs/synnax/pkg/service/auth/password" ) var _ = Describe("Password", func() { diff --git a/synnax/pkg/auth/token/token.go b/synnax/pkg/service/auth/token/token.go similarity index 98% rename from synnax/pkg/auth/token/token.go rename to synnax/pkg/service/auth/token/token.go index 52581086f0..e36ceae9b5 100644 --- a/synnax/pkg/auth/token/token.go +++ b/synnax/pkg/service/auth/token/token.go @@ -15,8 +15,8 @@ import ( "crypto/rsa" "github.com/golang-jwt/jwt" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/auth" "github.com/synnaxlabs/synnax/pkg/security" + "github.com/synnaxlabs/synnax/pkg/service/auth" "github.com/synnaxlabs/x/errors" "strings" "time" diff --git a/synnax/pkg/auth/token/token_suite_test.go b/synnax/pkg/service/auth/token/token_suite_test.go similarity index 100% rename from synnax/pkg/auth/token/token_suite_test.go rename to synnax/pkg/service/auth/token/token_suite_test.go diff --git a/synnax/pkg/auth/token/token_test.go b/synnax/pkg/service/auth/token/token_test.go similarity index 96% rename from synnax/pkg/auth/token/token_test.go rename to synnax/pkg/service/auth/token/token_test.go index fb48ee3988..4baf5b7999 100644 --- a/synnax/pkg/auth/token/token_test.go +++ b/synnax/pkg/service/auth/token/token_test.go @@ -16,7 +16,7 @@ import ( "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/auth/token" + "github.com/synnaxlabs/synnax/pkg/service/auth/token" "time" ) diff --git a/synnax/pkg/service/framer/downsampler/downsampler.go b/synnax/pkg/service/framer/downsampler/downsampler.go new file mode 100644 index 0000000000..328a9a985b --- /dev/null +++ b/synnax/pkg/service/framer/downsampler/downsampler.go @@ -0,0 +1,135 @@ +// Copyright 2023 Synnax Labs, Inc. +// +// Use of this software is governed by the Business Source License included in the file +// licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with the Business Source +// License, use of this software will be governed by the Apache License, Version 2.0, +// included in the file licenses/APL.txt. + +package downsampler + +import ( + "bytes" + "context" + "github.com/synnaxlabs/synnax/pkg/distribution/framer" + "github.com/synnaxlabs/x/address" + "github.com/synnaxlabs/x/confluence" + "github.com/synnaxlabs/x/confluence/plumber" + "github.com/synnaxlabs/x/telem" +) + +const defaultBuffer = 25 + +func NewStreamer( + ctx context.Context, + cfg framer.StreamerConfig, + service *framer.Service, +) (framer.Streamer, error) { + s, err := service.NewStreamer(ctx, cfg) + if err != nil { + return nil, err + } + downsampler := &confluence.LinearTransform[ + framer.StreamerResponse, + framer.StreamerResponse, + ]{ + Transform: func(ctx context.Context, i framer.StreamerResponse) ( + o framer.StreamerResponse, + ok bool, + err error, + ) { + i = downsample(ctx, i, cfg.DownsampleFactor) + return i, true, nil + }, + } + + pipe := plumber.New() + plumber.SetSegment[framer.StreamerRequest, framer.StreamerResponse]( + pipe, + "dist-streamer", + s, + ) + + plumber.SetSegment[framer.StreamerResponse, framer.StreamerResponse]( + pipe, + "downsampler", + downsampler, + ) + plumber.MustConnect[framer.StreamerResponse]( + pipe, + "dist-streamer", + "downsampler", + defaultBuffer, + ) + seg := &plumber.Segment[framer.StreamerRequest, framer.StreamerResponse]{ + Pipeline: pipe, + RouteInletsTo: []address.Address{"dist-streamer"}, + RouteOutletsFrom: []address.Address{"downsampler"}, + } + + return seg, nil +} + +func downsample( + ctx context.Context, + response framer.StreamerResponse, + factor int, +) framer.StreamerResponse { + if factor <= 1 { + return response + } + for i, series := range response.Frame.Series { + response.Frame.Series[i] = downsampleSeries(series, factor) + } + return response +} + +func downsampleSeries(series telem.Series, factor int) telem.Series { + length := len(series.Data) + if factor <= 1 || length <= factor { + return series + } + + if series.DataType.IsVariable() { + return downsampleVariable(series, factor) + } + + // Original downsampling logic for non-variable types + seriesLength := (len(series.Data) / factor) + downsampledData := make([]byte, 0, seriesLength) + for i := int64(0); i < series.Len(); i += int64(factor) { + start := i * int64(series.DataType.Density()) + end := start + int64(series.DataType.Density()) + downsampledData = append(downsampledData, series.Data[start:end]...) + } + + downsampledSeries := telem.Series{ + TimeRange: series.TimeRange, + DataType: series.DataType, + Data: downsampledData, + Alignment: series.Alignment, + } + return downsampledSeries +} + +func downsampleVariable(series telem.Series, factor int) telem.Series { + lines := bytes.Split(series.Data, []byte("\n")) + downsampledLines := make([][]byte, 0, len(lines)/factor+1) + + for i := 0; i < len(lines); i += factor { + if i < len(lines) { + downsampledLines = append(downsampledLines, lines[i]) + } + } + + downsampledData := bytes.Join(downsampledLines, []byte("\n")) + + downsampledSeries := telem.Series{ + TimeRange: series.TimeRange, + DataType: series.DataType, + Data: downsampledData, + Alignment: series.Alignment, + } + return downsampledSeries +} diff --git a/synnax/pkg/service/framer/service.go b/synnax/pkg/service/framer/service.go new file mode 100644 index 0000000000..ec3b2a93f9 --- /dev/null +++ b/synnax/pkg/service/framer/service.go @@ -0,0 +1,51 @@ +// Copyright 2023 Synnax Labs, Inc. +// +// Use of this software is governed by the Business Source License included in the file +// licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with the Business Source +// License, use of this software will be governed by the Apache License, Version 2.0, +// included in the file licenses/APL.txt. + +package framer + +import ( + "context" + + "github.com/synnaxlabs/synnax/pkg/distribution/framer" + "github.com/synnaxlabs/synnax/pkg/service/framer/downsampler" +) + +type Service struct { + Internal *framer.Service // distribution layer frame service +} + +func (s *Service) OpenIterator(ctx context.Context, cfg framer.IteratorConfig) (*framer.Iterator, error) { + return s.Internal.OpenIterator(ctx, cfg) +} + +func (s *Service) NewStreamIterator(ctx context.Context, cfg framer.IteratorConfig) (framer.StreamIterator, error) { + return s.Internal.NewStreamIterator(ctx, cfg) +} + +func (s *Service) NewStreamWriter(ctx context.Context, cfg framer.WriterConfig) (framer.StreamWriter, error) { + return s.Internal.NewStreamWriter(ctx, cfg) +} + +func (s *Service) NewDeleter() framer.Deleter { + return s.Internal.NewDeleter() +} + +func (s *Service) NewStreamer(ctx context.Context, cfg framer.StreamerConfig) (framer.Streamer, error) { + if cfg.DownsampleFactor > 1 { + return downsampler.NewStreamer(ctx, cfg, s.Internal) + } else { + return s.Internal.NewStreamer(ctx, cfg) + } +} + +func NewService(framerSvc *framer.Service) (*Service, error) { + return &Service{ + Internal: framerSvc, + }, nil +} diff --git a/synnax/pkg/hardware/device/device.go b/synnax/pkg/service/hardware/device/device.go similarity index 97% rename from synnax/pkg/hardware/device/device.go rename to synnax/pkg/service/hardware/device/device.go index 18f1eca291..fac4c33f31 100644 --- a/synnax/pkg/hardware/device/device.go +++ b/synnax/pkg/service/hardware/device/device.go @@ -12,7 +12,7 @@ package device import ( - "github.com/synnaxlabs/synnax/pkg/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/validate" ) diff --git a/synnax/pkg/hardware/device/ontology.go b/synnax/pkg/service/hardware/device/ontology.go similarity index 100% rename from synnax/pkg/hardware/device/ontology.go rename to synnax/pkg/service/hardware/device/ontology.go diff --git a/synnax/pkg/hardware/device/retrieve.go b/synnax/pkg/service/hardware/device/retrieve.go similarity index 100% rename from synnax/pkg/hardware/device/retrieve.go rename to synnax/pkg/service/hardware/device/retrieve.go diff --git a/synnax/pkg/hardware/device/service.go b/synnax/pkg/service/hardware/device/service.go similarity index 100% rename from synnax/pkg/hardware/device/service.go rename to synnax/pkg/service/hardware/device/service.go diff --git a/synnax/pkg/hardware/device/writer.go b/synnax/pkg/service/hardware/device/writer.go similarity index 100% rename from synnax/pkg/hardware/device/writer.go rename to synnax/pkg/service/hardware/device/writer.go diff --git a/synnax/pkg/hardware/embedded/assets/.gitkeep b/synnax/pkg/service/hardware/embedded/assets/.gitkeep similarity index 100% rename from synnax/pkg/hardware/embedded/assets/.gitkeep rename to synnax/pkg/service/hardware/embedded/assets/.gitkeep diff --git a/synnax/pkg/hardware/embedded/disabled.go b/synnax/pkg/service/hardware/embedded/disabled.go similarity index 100% rename from synnax/pkg/hardware/embedded/disabled.go rename to synnax/pkg/service/hardware/embedded/disabled.go diff --git a/synnax/pkg/hardware/embedded/driver.go b/synnax/pkg/service/hardware/embedded/driver.go similarity index 100% rename from synnax/pkg/hardware/embedded/driver.go rename to synnax/pkg/service/hardware/embedded/driver.go diff --git a/synnax/pkg/hardware/embedded/enabled.go b/synnax/pkg/service/hardware/embedded/enabled.go similarity index 100% rename from synnax/pkg/hardware/embedded/enabled.go rename to synnax/pkg/service/hardware/embedded/enabled.go diff --git a/synnax/pkg/hardware/embedded/unix_enabled.go b/synnax/pkg/service/hardware/embedded/unix_enabled.go similarity index 100% rename from synnax/pkg/hardware/embedded/unix_enabled.go rename to synnax/pkg/service/hardware/embedded/unix_enabled.go diff --git a/synnax/pkg/hardware/embedded/windows_enabled.go b/synnax/pkg/service/hardware/embedded/windows_enabled.go similarity index 100% rename from synnax/pkg/hardware/embedded/windows_enabled.go rename to synnax/pkg/service/hardware/embedded/windows_enabled.go diff --git a/synnax/pkg/hardware/rack/ontology.go b/synnax/pkg/service/hardware/rack/ontology.go similarity index 100% rename from synnax/pkg/hardware/rack/ontology.go rename to synnax/pkg/service/hardware/rack/ontology.go diff --git a/synnax/pkg/hardware/rack/rack.go b/synnax/pkg/service/hardware/rack/rack.go similarity index 100% rename from synnax/pkg/hardware/rack/rack.go rename to synnax/pkg/service/hardware/rack/rack.go diff --git a/synnax/pkg/hardware/rack/rack_suite_test.go b/synnax/pkg/service/hardware/rack/rack_suite_test.go similarity index 100% rename from synnax/pkg/hardware/rack/rack_suite_test.go rename to synnax/pkg/service/hardware/rack/rack_suite_test.go diff --git a/synnax/pkg/hardware/rack/rack_test.go b/synnax/pkg/service/hardware/rack/rack_test.go similarity index 98% rename from synnax/pkg/hardware/rack/rack_test.go rename to synnax/pkg/service/hardware/rack/rack_test.go index 8d093a9e13..d117f9dcdd 100644 --- a/synnax/pkg/hardware/rack/rack_test.go +++ b/synnax/pkg/service/hardware/rack/rack_test.go @@ -16,7 +16,7 @@ import ( "github.com/synnaxlabs/synnax/pkg/distribution/core/mock" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" "github.com/synnaxlabs/x/query" diff --git a/synnax/pkg/hardware/rack/retrieve.go b/synnax/pkg/service/hardware/rack/retrieve.go similarity index 100% rename from synnax/pkg/hardware/rack/retrieve.go rename to synnax/pkg/service/hardware/rack/retrieve.go diff --git a/synnax/pkg/hardware/rack/service.go b/synnax/pkg/service/hardware/rack/service.go similarity index 100% rename from synnax/pkg/hardware/rack/service.go rename to synnax/pkg/service/hardware/rack/service.go diff --git a/synnax/pkg/hardware/rack/writer.go b/synnax/pkg/service/hardware/rack/writer.go similarity index 100% rename from synnax/pkg/hardware/rack/writer.go rename to synnax/pkg/service/hardware/rack/writer.go diff --git a/synnax/pkg/hardware/service.go b/synnax/pkg/service/hardware/service.go similarity index 90% rename from synnax/pkg/hardware/service.go rename to synnax/pkg/service/hardware/service.go index a24c956981..463b97534b 100644 --- a/synnax/pkg/hardware/service.go +++ b/synnax/pkg/service/hardware/service.go @@ -14,10 +14,10 @@ package hardware import ( "context" "github.com/synnaxlabs/synnax/pkg/distribution/signals" - "github.com/synnaxlabs/synnax/pkg/hardware/device" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" - "github.com/synnaxlabs/synnax/pkg/hardware/state" - "github.com/synnaxlabs/synnax/pkg/hardware/task" + "github.com/synnaxlabs/synnax/pkg/service/hardware/device" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/state" + "github.com/synnaxlabs/synnax/pkg/service/hardware/task" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/errors" ) diff --git a/synnax/pkg/hardware/state/state_suite_test.go b/synnax/pkg/service/hardware/state/state_suite_test.go similarity index 100% rename from synnax/pkg/hardware/state/state_suite_test.go rename to synnax/pkg/service/hardware/state/state_suite_test.go diff --git a/synnax/pkg/hardware/state/tracker.go b/synnax/pkg/service/hardware/state/tracker.go similarity index 98% rename from synnax/pkg/hardware/state/tracker.go rename to synnax/pkg/service/hardware/state/tracker.go index 9d57301b0a..0a1cfa3d71 100644 --- a/synnax/pkg/hardware/state/tracker.go +++ b/synnax/pkg/service/hardware/state/tracker.go @@ -19,8 +19,8 @@ import ( "github.com/synnaxlabs/synnax/pkg/distribution/channel" "github.com/synnaxlabs/synnax/pkg/distribution/core" "github.com/synnaxlabs/synnax/pkg/distribution/signals" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" - "github.com/synnaxlabs/synnax/pkg/hardware/task" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/task" binaryx "github.com/synnaxlabs/x/binary" "github.com/synnaxlabs/x/change" "github.com/synnaxlabs/x/config" diff --git a/synnax/pkg/hardware/state/tracker_test.go b/synnax/pkg/service/hardware/state/tracker_test.go similarity index 97% rename from synnax/pkg/hardware/state/tracker_test.go rename to synnax/pkg/service/hardware/state/tracker_test.go index 551cd72b3d..cd5a258fa0 100644 --- a/synnax/pkg/hardware/state/tracker_test.go +++ b/synnax/pkg/service/hardware/state/tracker_test.go @@ -14,9 +14,9 @@ import ( . "github.com/onsi/gomega" "github.com/synnaxlabs/synnax/pkg/distribution/channel" "github.com/synnaxlabs/synnax/pkg/distribution/framer" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" - "github.com/synnaxlabs/synnax/pkg/hardware/state" - "github.com/synnaxlabs/synnax/pkg/hardware/task" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/state" + "github.com/synnaxlabs/synnax/pkg/service/hardware/task" "github.com/synnaxlabs/x/binary" "github.com/synnaxlabs/x/telem" . "github.com/synnaxlabs/x/testutil" diff --git a/synnax/pkg/hardware/task/ontology.go b/synnax/pkg/service/hardware/task/ontology.go similarity index 100% rename from synnax/pkg/hardware/task/ontology.go rename to synnax/pkg/service/hardware/task/ontology.go diff --git a/synnax/pkg/hardware/task/retrieve.go b/synnax/pkg/service/hardware/task/retrieve.go similarity index 97% rename from synnax/pkg/hardware/task/retrieve.go rename to synnax/pkg/service/hardware/task/retrieve.go index 05edd0cfda..fda4f2ea04 100644 --- a/synnax/pkg/hardware/task/retrieve.go +++ b/synnax/pkg/service/hardware/task/retrieve.go @@ -16,7 +16,7 @@ import ( "github.com/samber/lo" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/search" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/hardware/task/service.go b/synnax/pkg/service/hardware/task/service.go similarity index 98% rename from synnax/pkg/hardware/task/service.go rename to synnax/pkg/service/hardware/task/service.go index f633e6d8d5..0a14fd9578 100644 --- a/synnax/pkg/hardware/task/service.go +++ b/synnax/pkg/service/hardware/task/service.go @@ -22,7 +22,7 @@ import ( "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" "github.com/synnaxlabs/synnax/pkg/distribution/signals" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/override" diff --git a/synnax/pkg/hardware/task/task.go b/synnax/pkg/service/hardware/task/task.go similarity index 98% rename from synnax/pkg/hardware/task/task.go rename to synnax/pkg/service/hardware/task/task.go index 5e53acf946..d618a526c6 100644 --- a/synnax/pkg/hardware/task/task.go +++ b/synnax/pkg/service/hardware/task/task.go @@ -16,7 +16,7 @@ import ( "fmt" "strconv" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/types" diff --git a/synnax/pkg/hardware/task/task_suite_test.go b/synnax/pkg/service/hardware/task/task_suite_test.go similarity index 100% rename from synnax/pkg/hardware/task/task_suite_test.go rename to synnax/pkg/service/hardware/task/task_suite_test.go diff --git a/synnax/pkg/hardware/task/task_test.go b/synnax/pkg/service/hardware/task/task_test.go similarity index 97% rename from synnax/pkg/hardware/task/task_test.go rename to synnax/pkg/service/hardware/task/task_test.go index a2f2776cc2..cbf18da78c 100644 --- a/synnax/pkg/hardware/task/task_test.go +++ b/synnax/pkg/service/hardware/task/task_test.go @@ -16,8 +16,8 @@ import ( "github.com/synnaxlabs/synnax/pkg/distribution/core/mock" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" - "github.com/synnaxlabs/synnax/pkg/hardware/task" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/task" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" "github.com/synnaxlabs/x/query" diff --git a/synnax/pkg/hardware/task/writer.go b/synnax/pkg/service/hardware/task/writer.go similarity index 97% rename from synnax/pkg/hardware/task/writer.go rename to synnax/pkg/service/hardware/task/writer.go index c8d7900af7..c5731c9a53 100644 --- a/synnax/pkg/hardware/task/writer.go +++ b/synnax/pkg/service/hardware/task/writer.go @@ -15,7 +15,7 @@ import ( "context" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/hardware/rack" + "github.com/synnaxlabs/synnax/pkg/service/hardware/rack" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/label/label.go b/synnax/pkg/service/label/label.go similarity index 100% rename from synnax/pkg/label/label.go rename to synnax/pkg/service/label/label.go diff --git a/synnax/pkg/label/label_suite_test.go b/synnax/pkg/service/label/label_suite_test.go similarity index 100% rename from synnax/pkg/label/label_suite_test.go rename to synnax/pkg/service/label/label_suite_test.go diff --git a/synnax/pkg/label/label_test.go b/synnax/pkg/service/label/label_test.go similarity index 98% rename from synnax/pkg/label/label_test.go rename to synnax/pkg/service/label/label_test.go index 60ce9e026a..44566f1b9e 100644 --- a/synnax/pkg/label/label_test.go +++ b/synnax/pkg/service/label/label_test.go @@ -15,13 +15,12 @@ import ( . "github.com/onsi/gomega" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" + "github.com/synnaxlabs/synnax/pkg/service/label" "github.com/synnaxlabs/x/color" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" "github.com/synnaxlabs/x/query" . "github.com/synnaxlabs/x/testutil" - - "github.com/synnaxlabs/synnax/pkg/label" ) var _ = Describe("Label", Ordered, func() { @@ -69,7 +68,7 @@ var _ = Describe("Label", Ordered, func() { Color: color.Color("#000000"), }, { - Name: "Label2", + Name: "label", Color: color.Color("#000000"), }, } @@ -96,7 +95,7 @@ var _ = Describe("Label", Ordered, func() { Color: color.Color("#000000"), }, { - Name: "Label2", + Name: "label", Color: color.Color("#000000"), }, } diff --git a/synnax/pkg/label/ontology.go b/synnax/pkg/service/label/ontology.go similarity index 100% rename from synnax/pkg/label/ontology.go rename to synnax/pkg/service/label/ontology.go diff --git a/synnax/pkg/label/relationship.go b/synnax/pkg/service/label/relationship.go similarity index 100% rename from synnax/pkg/label/relationship.go rename to synnax/pkg/service/label/relationship.go diff --git a/synnax/pkg/label/retrieve.go b/synnax/pkg/service/label/retrieve.go similarity index 100% rename from synnax/pkg/label/retrieve.go rename to synnax/pkg/service/label/retrieve.go diff --git a/synnax/pkg/label/service.go b/synnax/pkg/service/label/service.go similarity index 100% rename from synnax/pkg/label/service.go rename to synnax/pkg/service/label/service.go diff --git a/synnax/pkg/label/writer.go b/synnax/pkg/service/label/writer.go similarity index 100% rename from synnax/pkg/label/writer.go rename to synnax/pkg/service/label/writer.go diff --git a/synnax/pkg/ranger/alias.go b/synnax/pkg/service/ranger/alias.go similarity index 100% rename from synnax/pkg/ranger/alias.go rename to synnax/pkg/service/ranger/alias.go diff --git a/synnax/pkg/ranger/kv.go b/synnax/pkg/service/ranger/kv.go similarity index 100% rename from synnax/pkg/ranger/kv.go rename to synnax/pkg/service/ranger/kv.go diff --git a/synnax/pkg/ranger/ontology.go b/synnax/pkg/service/ranger/ontology.go similarity index 100% rename from synnax/pkg/ranger/ontology.go rename to synnax/pkg/service/ranger/ontology.go diff --git a/synnax/pkg/ranger/range.go b/synnax/pkg/service/ranger/range.go similarity index 100% rename from synnax/pkg/ranger/range.go rename to synnax/pkg/service/ranger/range.go diff --git a/synnax/pkg/ranger/ranger_suite_test.go b/synnax/pkg/service/ranger/ranger_suite_test.go similarity index 100% rename from synnax/pkg/ranger/ranger_suite_test.go rename to synnax/pkg/service/ranger/ranger_suite_test.go diff --git a/synnax/pkg/ranger/ranger_test.go b/synnax/pkg/service/ranger/ranger_test.go similarity index 99% rename from synnax/pkg/ranger/ranger_test.go rename to synnax/pkg/service/ranger/ranger_test.go index 31dd922f29..65884dba3e 100644 --- a/synnax/pkg/ranger/ranger_test.go +++ b/synnax/pkg/service/ranger/ranger_test.go @@ -16,7 +16,7 @@ import ( "github.com/synnaxlabs/synnax/pkg/distribution/channel" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/ranger" + "github.com/synnaxlabs/synnax/pkg/service/ranger" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/gorp" xio "github.com/synnaxlabs/x/io" diff --git a/synnax/pkg/ranger/retrieve.go b/synnax/pkg/service/ranger/retrieve.go similarity index 100% rename from synnax/pkg/ranger/retrieve.go rename to synnax/pkg/service/ranger/retrieve.go diff --git a/synnax/pkg/ranger/service.go b/synnax/pkg/service/ranger/service.go similarity index 100% rename from synnax/pkg/ranger/service.go rename to synnax/pkg/service/ranger/service.go diff --git a/synnax/pkg/ranger/writer.go b/synnax/pkg/service/ranger/writer.go similarity index 100% rename from synnax/pkg/ranger/writer.go rename to synnax/pkg/service/ranger/writer.go diff --git a/synnax/pkg/user/ontology.go b/synnax/pkg/service/user/ontology.go similarity index 100% rename from synnax/pkg/user/ontology.go rename to synnax/pkg/service/user/ontology.go diff --git a/synnax/pkg/user/ontology_test.go b/synnax/pkg/service/user/ontology_test.go similarity index 97% rename from synnax/pkg/user/ontology_test.go rename to synnax/pkg/service/user/ontology_test.go index 12e517aa48..e335cdc350 100644 --- a/synnax/pkg/user/ontology_test.go +++ b/synnax/pkg/service/user/ontology_test.go @@ -16,7 +16,7 @@ import ( "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/schema" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/user" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" . "github.com/synnaxlabs/x/testutil" diff --git a/synnax/pkg/user/retrieve.go b/synnax/pkg/service/user/retrieve.go similarity index 100% rename from synnax/pkg/user/retrieve.go rename to synnax/pkg/service/user/retrieve.go diff --git a/synnax/pkg/user/service.go b/synnax/pkg/service/user/service.go similarity index 100% rename from synnax/pkg/user/service.go rename to synnax/pkg/service/user/service.go diff --git a/synnax/pkg/user/service_test.go b/synnax/pkg/service/user/service_test.go similarity index 98% rename from synnax/pkg/user/service_test.go rename to synnax/pkg/service/user/service_test.go index 20a9eb0938..d0cb9ccd58 100644 --- a/synnax/pkg/user/service_test.go +++ b/synnax/pkg/service/user/service_test.go @@ -13,10 +13,10 @@ import ( "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/auth" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/auth" + "github.com/synnaxlabs/synnax/pkg/service/user" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" diff --git a/synnax/pkg/user/user.go b/synnax/pkg/service/user/user.go similarity index 100% rename from synnax/pkg/user/user.go rename to synnax/pkg/service/user/user.go diff --git a/synnax/pkg/user/user_suite_test.go b/synnax/pkg/service/user/user_suite_test.go similarity index 100% rename from synnax/pkg/user/user_suite_test.go rename to synnax/pkg/service/user/user_suite_test.go diff --git a/synnax/pkg/user/writer.go b/synnax/pkg/service/user/writer.go similarity index 98% rename from synnax/pkg/user/writer.go rename to synnax/pkg/service/user/writer.go index 1a373ea517..9f89b5ee63 100644 --- a/synnax/pkg/user/writer.go +++ b/synnax/pkg/service/user/writer.go @@ -13,8 +13,8 @@ import ( "context" "github.com/google/uuid" - "github.com/synnaxlabs/synnax/pkg/auth" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" + "github.com/synnaxlabs/synnax/pkg/service/auth" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/workspace/lineplot/lineplot.go b/synnax/pkg/service/workspace/lineplot/lineplot.go similarity index 100% rename from synnax/pkg/workspace/lineplot/lineplot.go rename to synnax/pkg/service/workspace/lineplot/lineplot.go diff --git a/synnax/pkg/workspace/lineplot/lineplot_suite_test.go b/synnax/pkg/service/workspace/lineplot/lineplot_suite_test.go similarity index 92% rename from synnax/pkg/workspace/lineplot/lineplot_suite_test.go rename to synnax/pkg/service/workspace/lineplot/lineplot_suite_test.go index 3dc26566a7..e43435425c 100644 --- a/synnax/pkg/workspace/lineplot/lineplot_suite_test.go +++ b/synnax/pkg/service/workspace/lineplot/lineplot_suite_test.go @@ -17,9 +17,9 @@ import ( . "github.com/onsi/gomega" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/user" - "github.com/synnaxlabs/synnax/pkg/workspace" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" + "github.com/synnaxlabs/synnax/pkg/service/user" + "github.com/synnaxlabs/synnax/pkg/service/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" diff --git a/synnax/pkg/workspace/lineplot/ontology.go b/synnax/pkg/service/workspace/lineplot/ontology.go similarity index 100% rename from synnax/pkg/workspace/lineplot/ontology.go rename to synnax/pkg/service/workspace/lineplot/ontology.go diff --git a/synnax/pkg/workspace/lineplot/retrieve.go b/synnax/pkg/service/workspace/lineplot/retrieve.go similarity index 100% rename from synnax/pkg/workspace/lineplot/retrieve.go rename to synnax/pkg/service/workspace/lineplot/retrieve.go diff --git a/synnax/pkg/workspace/lineplot/retrieve_test.go b/synnax/pkg/service/workspace/lineplot/retrieve_test.go similarity index 92% rename from synnax/pkg/workspace/lineplot/retrieve_test.go rename to synnax/pkg/service/workspace/lineplot/retrieve_test.go index 5df199981b..4ab787527b 100644 --- a/synnax/pkg/workspace/lineplot/retrieve_test.go +++ b/synnax/pkg/service/workspace/lineplot/retrieve_test.go @@ -12,7 +12,7 @@ package lineplot_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" ) var _ = Describe("Retrieve", func() { diff --git a/synnax/pkg/workspace/lineplot/service.go b/synnax/pkg/service/workspace/lineplot/service.go similarity index 100% rename from synnax/pkg/workspace/lineplot/service.go rename to synnax/pkg/service/workspace/lineplot/service.go diff --git a/synnax/pkg/workspace/lineplot/writer.go b/synnax/pkg/service/workspace/lineplot/writer.go similarity index 97% rename from synnax/pkg/workspace/lineplot/writer.go rename to synnax/pkg/service/workspace/lineplot/writer.go index a41521a421..ccce3dea7c 100644 --- a/synnax/pkg/workspace/lineplot/writer.go +++ b/synnax/pkg/service/workspace/lineplot/writer.go @@ -13,7 +13,7 @@ import ( "context" "github.com/google/uuid" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/workspace/lineplot/writer_test.go b/synnax/pkg/service/workspace/lineplot/writer_test.go similarity index 96% rename from synnax/pkg/workspace/lineplot/writer_test.go rename to synnax/pkg/service/workspace/lineplot/writer_test.go index a42fa297d5..dcc866404d 100644 --- a/synnax/pkg/workspace/lineplot/writer_test.go +++ b/synnax/pkg/service/workspace/lineplot/writer_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/workspace/ontology.go b/synnax/pkg/service/workspace/ontology.go similarity index 100% rename from synnax/pkg/workspace/ontology.go rename to synnax/pkg/service/workspace/ontology.go diff --git a/synnax/pkg/workspace/retrieve.go b/synnax/pkg/service/workspace/retrieve.go similarity index 100% rename from synnax/pkg/workspace/retrieve.go rename to synnax/pkg/service/workspace/retrieve.go diff --git a/synnax/pkg/workspace/retrieve_test.go b/synnax/pkg/service/workspace/retrieve_test.go similarity index 94% rename from synnax/pkg/workspace/retrieve_test.go rename to synnax/pkg/service/workspace/retrieve_test.go index adf7eeb604..87aae73a09 100644 --- a/synnax/pkg/workspace/retrieve_test.go +++ b/synnax/pkg/service/workspace/retrieve_test.go @@ -12,7 +12,7 @@ package workspace_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace" ) var _ = Describe("Retrieve", func() { diff --git a/synnax/pkg/workspace/schematic/ontology.go b/synnax/pkg/service/workspace/schematic/ontology.go similarity index 100% rename from synnax/pkg/workspace/schematic/ontology.go rename to synnax/pkg/service/workspace/schematic/ontology.go diff --git a/synnax/pkg/workspace/schematic/retrieve.go b/synnax/pkg/service/workspace/schematic/retrieve.go similarity index 100% rename from synnax/pkg/workspace/schematic/retrieve.go rename to synnax/pkg/service/workspace/schematic/retrieve.go diff --git a/synnax/pkg/workspace/schematic/retrieve_test.go b/synnax/pkg/service/workspace/schematic/retrieve_test.go similarity index 92% rename from synnax/pkg/workspace/schematic/retrieve_test.go rename to synnax/pkg/service/workspace/schematic/retrieve_test.go index c31e434411..0e9117db09 100644 --- a/synnax/pkg/workspace/schematic/retrieve_test.go +++ b/synnax/pkg/service/workspace/schematic/retrieve_test.go @@ -12,7 +12,7 @@ package schematic_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" ) var _ = Describe("Retrieve", func() { diff --git a/synnax/pkg/workspace/schematic/schematic.go b/synnax/pkg/service/workspace/schematic/schematic.go similarity index 100% rename from synnax/pkg/workspace/schematic/schematic.go rename to synnax/pkg/service/workspace/schematic/schematic.go diff --git a/synnax/pkg/workspace/schematic/schematic_suite_test.go b/synnax/pkg/service/workspace/schematic/schematic_suite_test.go similarity index 92% rename from synnax/pkg/workspace/schematic/schematic_suite_test.go rename to synnax/pkg/service/workspace/schematic/schematic_suite_test.go index 178e44f728..dc397b72f8 100644 --- a/synnax/pkg/workspace/schematic/schematic_suite_test.go +++ b/synnax/pkg/service/workspace/schematic/schematic_suite_test.go @@ -15,9 +15,9 @@ import ( "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/user" - "github.com/synnaxlabs/synnax/pkg/workspace" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" + "github.com/synnaxlabs/synnax/pkg/service/user" + "github.com/synnaxlabs/synnax/pkg/service/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" diff --git a/synnax/pkg/workspace/schematic/service.go b/synnax/pkg/service/workspace/schematic/service.go similarity index 100% rename from synnax/pkg/workspace/schematic/service.go rename to synnax/pkg/service/workspace/schematic/service.go diff --git a/synnax/pkg/workspace/schematic/writer.go b/synnax/pkg/service/workspace/schematic/writer.go similarity index 98% rename from synnax/pkg/workspace/schematic/writer.go rename to synnax/pkg/service/workspace/schematic/writer.go index 0f651f33ec..bd688290ff 100644 --- a/synnax/pkg/workspace/schematic/writer.go +++ b/synnax/pkg/service/workspace/schematic/writer.go @@ -14,7 +14,7 @@ import ( "github.com/google/uuid" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace" "github.com/synnaxlabs/x/errors" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/validate" diff --git a/synnax/pkg/workspace/schematic/writer_test.go b/synnax/pkg/service/workspace/schematic/writer_test.go similarity index 97% rename from synnax/pkg/workspace/schematic/writer_test.go rename to synnax/pkg/service/workspace/schematic/writer_test.go index fe542bbc06..a84d3bd5e6 100644 --- a/synnax/pkg/workspace/schematic/writer_test.go +++ b/synnax/pkg/service/workspace/schematic/writer_test.go @@ -15,7 +15,7 @@ import ( . "github.com/onsi/gomega" "github.com/samber/lo" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" - "github.com/synnaxlabs/synnax/pkg/workspace/schematic" + "github.com/synnaxlabs/synnax/pkg/service/workspace/schematic" "github.com/synnaxlabs/x/gorp" . "github.com/synnaxlabs/x/testutil" "github.com/synnaxlabs/x/validate" diff --git a/synnax/pkg/workspace/service.go b/synnax/pkg/service/workspace/service.go similarity index 100% rename from synnax/pkg/workspace/service.go rename to synnax/pkg/service/workspace/service.go diff --git a/synnax/pkg/workspace/workspace.go b/synnax/pkg/service/workspace/workspace.go similarity index 100% rename from synnax/pkg/workspace/workspace.go rename to synnax/pkg/service/workspace/workspace.go diff --git a/synnax/pkg/workspace/workspace_suite_test.go b/synnax/pkg/service/workspace/workspace_suite_test.go similarity index 94% rename from synnax/pkg/workspace/workspace_suite_test.go rename to synnax/pkg/service/workspace/workspace_suite_test.go index f617a678e2..c09a73039c 100644 --- a/synnax/pkg/workspace/workspace_suite_test.go +++ b/synnax/pkg/service/workspace/workspace_suite_test.go @@ -17,8 +17,8 @@ import ( . "github.com/onsi/gomega" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/user" - "github.com/synnaxlabs/synnax/pkg/workspace" + "github.com/synnaxlabs/synnax/pkg/service/user" + "github.com/synnaxlabs/synnax/pkg/service/workspace" "github.com/synnaxlabs/x/config" "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/kv/memkv" diff --git a/synnax/pkg/workspace/writer.go b/synnax/pkg/service/workspace/writer.go similarity index 97% rename from synnax/pkg/workspace/writer.go rename to synnax/pkg/service/workspace/writer.go index 667b521a98..c29ba387e8 100644 --- a/synnax/pkg/workspace/writer.go +++ b/synnax/pkg/service/workspace/writer.go @@ -14,7 +14,7 @@ import ( "github.com/google/uuid" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" "github.com/synnaxlabs/synnax/pkg/distribution/ontology/group" - "github.com/synnaxlabs/synnax/pkg/user" + "github.com/synnaxlabs/synnax/pkg/service/user" "github.com/synnaxlabs/x/gorp" ) diff --git a/synnax/pkg/workspace/writer_test.go b/synnax/pkg/service/workspace/writer_test.go similarity index 97% rename from synnax/pkg/workspace/writer_test.go rename to synnax/pkg/service/workspace/writer_test.go index 2476d7e653..44180e460f 100644 --- a/synnax/pkg/workspace/writer_test.go +++ b/synnax/pkg/service/workspace/writer_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/synnaxlabs/synnax/pkg/workspace" + "github.com/synnaxlabs/synnax/pkg/service/workspace" "github.com/synnaxlabs/x/gorp" )