Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
added chip for json link
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiaArt committed Aug 4, 2022
2 parents c1b4e86 + e3f258e commit 60751f9
Show file tree
Hide file tree
Showing 91 changed files with 2,676 additions and 2,112 deletions.
13 changes: 6 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ AUTH_PASSWORD=secret
LOG_CHANNEL=stderr
LOG_LEVEL=debug

DB_CONNECTION=sqlite

#DB_CONNECTION=mysql
#DB_DATABASE=database_name
#DB_USERNAME=database_username
#DB_PASSWORD=database_password
#DB_HOST=localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_SCHEMA_SYNC=false

BROADCAST_DRIVER=roadrunner
CACHE_DRIVER=roadrunner
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
build-args:
APP_VERSION=${{ steps.previoustag.outputs.tag }}
tags:
${{ secrets.DOCKER_HUB_USERNAME }}/buggregator:${{ steps.previoustag.outputs.tag }}
${{ secrets.DOCKER_HUB_USERNAME }}/buggregator:beta, ${{ secrets.DOCKER_HUB_USERNAME }}/buggregator:${{ steps.previoustag.outputs.tag }}
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.0' ]
php-versions: [ '8.1' ]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.0', '8.1' ]
php-versions: [ '8.1' ]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions .rr.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: "2.7"

rpc:
listen: tcp:https://127.0.0.1:6001

Expand Down Expand Up @@ -56,8 +58,10 @@ jobs:
pipelines:
default:
driver: memory
config: { }
events:
driver: memory
config: { }
pool:
num_workers: 2

Expand Down
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
FROM php:8.0-alpine
FROM php:8.1-alpine

# Optional, force UTC as server time
RUN echo "UTC" > /etc/timezone

RUN docker-php-ext-install opcache && docker-php-ext-enable opcache
RUN docker-php-ext-install pcntl
RUN apk add --no-cache libzip-dev sqlite-dev supervisor git && \
RUN apk add --no-cache libzip-dev sqlite-dev git && \
docker-php-ext-configure zip && \
docker-php-ext-install zip

RUN set -ex && apk --no-cache add postgresql-dev
RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS
RUN docker-php-ext-install pdo pdo_sqlite pdo_pgsql pdo_mysql sockets
RUN docker-php-ext-install pdo pdo_pgsql pdo_mysql sockets

RUN apk add --update mysql mysql-client && rm -f /var/cache/apk/*

RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

Expand All @@ -20,11 +22,15 @@ WORKDIR /app
ARG CACHEBUST=1
ARG APP_VERSION=v1.0

COPY docker/server/startup.sh /startup.sh
COPY docker/server/my.cnf /etc/mysql/my.cnf

RUN git clone https://github.com/buggregator/app.git /app
RUN composer install

RUN chmod 0777 storage -R
RUN chmod 0777 bootstrap -R
RUN chmod +x /startup.sh

# Create .env file
RUN cp .env.example .env
Expand All @@ -35,5 +41,6 @@ EXPOSE 8000
EXPOSE 1025
EXPOSE 9912
EXPOSE 9913
EXPOSE 3306

CMD ./rr serve
CMD sh -c /startup.sh
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Also you can use a termial to collect dump output if you don't want to use a bro

## Technological stack

- [Laravel 8](https://laravel.com/)
- [Laravel 9](https://laravel.com/)
- [InertiaJs](https://inertiajs.com/)
- [RoadRunner](https://roadrunner.dev/) Http, Websocket, TCP, Queue, Cache server in one bottle
- [Vue](https://vuejs.org/)
Expand All @@ -298,19 +298,26 @@ You can run Buggregator via docker from [Docker Hub](https://hub.docker.com/repo

Just run one of bash command

**Latest version**
**Latest stable release**

```bash
docker run --pull always -p 23517:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 butschster/buggregator:latest
```

**Latest beta release**
```bash
docker run --pull always -p 23517:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 butschster/buggregator:beta
```

You can omit `--pull always` argument if your docker-compose doesn't support it.

**Specific version**

```bash
docker run -p 23517:8000 -p 1025:1025 -p 9912:9912 -p 9913:9913 butschster/buggregator:v1.18
```

**You can omit unused ports if you use, for example, only var-dumper**
**You can omit unused ports if you use, for example, only `var-dumper`**
```bash
docker run --pull always -p 9912:9912 butschster/buggregator:latest
```
Expand Down
3 changes: 2 additions & 1 deletion app/Application/Commands/FindAllEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ final class FindAllEvents implements Query
{
// TODO: use readonly property
public function __construct(
public ?string $type = null
public ?string $type = null,
public ?int $projectId = null,
) {
}
}
9 changes: 9 additions & 0 deletions app/Application/Commands/FindAllProjects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace App\Commands;

use App\Contracts\Query\Query;

class FindAllProjects implements Query
{
}
13 changes: 13 additions & 0 deletions app/Application/Commands/FindProjectByName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Commands;

use App\Contracts\Query\Query;

class FindProjectByName implements Query
{
public function __construct(
public string $name
) {
}
}
2 changes: 2 additions & 0 deletions app/Application/Commands/HandleReceivedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class HandleReceivedEvent implements Command
public int $timestamp;

public function __construct(
public int $projectId,
public string $type,
public array $payload,
public bool $sendToConsole = false
Expand All @@ -24,6 +25,7 @@ public function __construct(
public function toArray(): array
{
return [
'projectId' => $this->projectId,
'type' => $this->type,
'payload' => $this->payload,
'uuid' => (string) $this->uuid,
Expand Down
2 changes: 1 addition & 1 deletion app/Application/Domain/Entity/ExtendedTypecast.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ private function uncastUuid(mixed $value): string

private function uncastJson(mixed $value): string
{
return (string)$value;
return (string) $value;
}
}
10 changes: 8 additions & 2 deletions app/Infrastructure/CycleOrm/Database/Drivers/SQLiteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class SQLiteDriver extends \Cycle\Database\Driver\SQLite\SQLiteDriver
{
public static function create(DriverConfig $config): self
public static function create(DriverConfig $config): static
{
return new self(
$config,
Expand All @@ -37,7 +37,13 @@ public function connect(): void

public function disconnect(): void
{
try {
$this->getLock()->forceRelease();
} catch (\Throwable $e) {
$this->logger?->error(
\sprintf('Lock [%s] can not be released. Reason: %s', 'driver.'.$this->getType(), $e->getMessage())
);
}
parent::disconnect();
$this->getLock()->forceRelease();
}
}
4 changes: 0 additions & 4 deletions app/Infrastructure/RoadRunner/Cache/CacheServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ public function register()
Cache::extend('roadrunner', function ($app) {
$factory = new Factory(RPC::create(config('roadrunner.rpc.host')));

if (! $factory->isAvailable()) {
return Cache::driver('array');
}

return Cache::repository(
new RoadRunnerStore(
$factory->select(config('roadrunner.cache.storage', 'cache'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function __construct(
public Uuid $uuid,
public DateTimeImmutable $date,
public array $payload,
public int $projectId,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function handle(Command $command): void
$command->uuid,
$command->type,
new Json($command->payload),
$command->date
$command->date,
$command->projectId
)
);

Expand All @@ -44,13 +45,14 @@ public function __invoke(HandleReceivedEvent $command): void
type: $command->type,
uuid: $command->uuid,
date: Carbon::createFromTimestamp($command->timestamp)->toDateTimeImmutable(),
payload: $command->payload
payload: $command->payload,
projectId: $command->projectId
)
);

$this->dispatcher->dispatch(
new EventWasReceived(
$command->uuid, $command->type, $command->payload, $command->timestamp, $command->sendToConsole
$command->projectId, $command->uuid, $command->type, $command->payload, $command->timestamp, $command->sendToConsole
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function __invoke(FindAllEvents $query): iterable
if ($query->type) {
$scope['type'] = $query->type;
}
if ($query->projectId) {
$scope['project_id'] = $query->projectId;
}

return EventCollection::make(
$this->events->findAll($scope, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function __construct(private EventRepository $events)
#[\App\Attributes\QueryBus\QueryHandler]
public function __invoke(FindEventByUuid $query): EventResource
{
$event = $this->events->findByPK((string)$query->uuid);
$event = $this->events->findByPK((string) $query->uuid);
if (! $event) {
throw new EntityNotFoundException(
sprintf('Event with given uuid [%s] was not found.', (string)$query->uuid)
sprintf('Event with given uuid [%s] was not found.', (string) $query->uuid)
);
}

Expand Down
10 changes: 9 additions & 1 deletion app/Modules/Events/Domain/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function __construct(
private Json $payload,

#[Column(type: 'datetime')]
private DateTimeImmutable $date
private DateTimeImmutable $date,

#[Column(type: 'integer', nullable: false)]
private int $projectId
) {
}

Expand All @@ -51,4 +54,9 @@ public function getDate(): DateTimeImmutable
{
return $this->date;
}

public function getProjectId(): int
{
return $this->projectId;
}
}
10 changes: 5 additions & 5 deletions app/Modules/Events/Interfaces/Http/Controllers/ListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class ListAction extends Controller
{
#[Get(uri: '/', name: 'events', middleware: 'auth')]
public function eventList(Request $request, QueryBus $bus, ActionMap $actionMap, ?string $type = null)
public function eventList(Request $request, QueryBus $bus, ActionMap $actionMap, ?string $type = null, ?int $projectId = null)
{
$action = 'Events';
if ($type) {
Expand All @@ -28,15 +28,15 @@ public function eventList(Request $request, QueryBus $bus, ActionMap $actionMap,
}

return Inertia::render($action, [
'events' => $bus->ask(new FindAllEvents(type: $type)),
'events' => $bus->ask(new FindAllEvents(type: $type, projectId: $projectId)),
'version' => config('app.version'),
'name' => config('app.name'),
]);
}

#[Get(uri: '/events/{type}', name: 'events.type')]
public function eventListByType(Request $request, QueryBus $bus, ActionMap $actionMap, string $type)
#[Get(uri: '/events/type/{type}/{projectId?}', name: 'events.type')]
public function eventListByType(Request $request, QueryBus $bus, ActionMap $actionMap, string $type, ?int $projectId = null)
{
return $this->eventList($request, $bus, $actionMap, $type);
return $this->eventList($request, $bus, $actionMap, $type, $projectId);
}
}
3 changes: 2 additions & 1 deletion app/Modules/Events/Projectors/EventProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function onEventWasReceived(EventWasReceived $event): void
$event->type,
$event->uuid,
Carbon::createFromTimestamp($event->timestamp)->toDateTimeImmutable(),
$event->payload
$event->payload,
$event->projectId
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __invoke(HandleReceivedEvent $command): void
{
$this->repository->persist(
EventProcess::received(
$command->projectId,
$command->uuid,
$command->type,
$command->payload,
Expand Down
4 changes: 2 additions & 2 deletions app/Modules/IncommingEvents/Domain/EventProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ final class EventProcess implements AggregateRoot
private DateTimeImmutable $date;
private bool $deleted = false;

public static function received(Uuid $uuid, string $type, array $payload, int $timestamp): static
public static function received(int $projectId, Uuid $uuid, string $type, array $payload, int $timestamp): static
{
$process = new static($uuid);
$process->recordThat(
new EventWasReceived($uuid, $type, $payload, $timestamp)
new EventWasReceived($projectId, $uuid, $type, $payload, $timestamp)
);

return $process;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class EventWasReceived implements Event, ShouldBroadcastNow
{
// TODO: use readonly property
public function __construct(
public int $projectId,
public Uuid $uuid,
public string $type,
public array $payload,
Expand All @@ -25,6 +26,7 @@ public function __construct(
public function toPayload(): array
{
return [
'projectId' => $this->projectId,
'uuid' => (string) $this->uuid,
'type' => $this->type,
'payload' => $this->payload,
Expand Down
Loading

0 comments on commit 60751f9

Please sign in to comment.