mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
revng daemon: add save mutation
Add the `save` mutation to the GraphQL api. This allows a client to trigger saving.
This commit is contained in:
committed by
Alessandro Di Federico
parent
319b558ddb
commit
f6f512883a
@@ -52,7 +52,7 @@ class Manager:
|
||||
def uid(self) -> int:
|
||||
return int(ffi.cast("uintptr_t", self._manager))
|
||||
|
||||
def save(self):
|
||||
def save(self) -> bool:
|
||||
return _api.rp_manager_save(self._manager)
|
||||
|
||||
# description utilities
|
||||
|
||||
@@ -6,7 +6,7 @@ import time
|
||||
from enum import StrEnum, auto
|
||||
from functools import wraps
|
||||
from threading import Thread
|
||||
from typing import Callable, Iterable
|
||||
from typing import Callable, Iterable, cast
|
||||
|
||||
from revng.internal.api import Manager
|
||||
|
||||
@@ -60,12 +60,12 @@ class EventManager(Thread):
|
||||
self.last_save = time.time()
|
||||
time.sleep(10)
|
||||
|
||||
def save(self):
|
||||
def save(self) -> bool:
|
||||
result = self.manager.save()
|
||||
if result:
|
||||
self.next_save = None
|
||||
for hook in self.save_hooks:
|
||||
hook(self.manager, self.credentials)
|
||||
hook(self.manager, cast(str, self.credentials))
|
||||
return result
|
||||
|
||||
def handle_event(self, type_: EventType):
|
||||
|
||||
@@ -21,7 +21,7 @@ from revng.internal.api.errors import DocumentError, Error, SimpleError
|
||||
from revng.internal.api.manager import Manager
|
||||
from revng.internal.api.target import Target
|
||||
|
||||
from .event_manager import EventType, emit_event
|
||||
from .event_manager import EventManager, EventType, emit_event
|
||||
from .multiqueue import MultiQueue
|
||||
from .util import produce_serializer
|
||||
|
||||
@@ -171,6 +171,12 @@ async def resolve_context_commit_index(_, info) -> int:
|
||||
return await run_in_executor(manager.get_context_commit_index)
|
||||
|
||||
|
||||
@mutation.field("save")
|
||||
async def resolve_save(_, info) -> bool:
|
||||
event_manager: EventManager = info.context["event_manager"]
|
||||
return await run_in_executor(event_manager.save)
|
||||
|
||||
|
||||
@mutation.field("uploadB64")
|
||||
@emit_event(EventType.BEGIN)
|
||||
async def resolve_upload_b64(_, info, *, input: str, container: str): # noqa: A002
|
||||
|
||||
@@ -28,6 +28,7 @@ type Target {
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
save: Boolean!
|
||||
uploadB64(input: String!, container: String!): Boolean!
|
||||
uploadFile(file: Upload, container: String!): Boolean!
|
||||
runAnalysis(step: String!, analysis: String!, containerToTargets: String, options: String, index: BigInt!): AnalysisResult!
|
||||
|
||||
Reference in New Issue
Block a user