// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using EpicGames.Horde.Jobs.Templates;
using EpicGames.Horde.Streams;
namespace EpicGames.Horde.Issues
{
///
/// Marks an issue handler that should be automatically inserted into the pipeline
///
[AttributeUsage(AttributeTargets.Class)]
public sealed class IssueHandlerAttribute : Attribute
{
///
/// Class of handler which can be explicitly enabled via a workflow
///
public string? Tag { get; set; }
}
///
/// Interface for issue matchers
///
public abstract class IssueHandler
{
///
/// Priority value for this issue handler. Handlers are processed in order of decreasing priority.
///
public abstract int Priority { get; }
///
/// Attempts to assign a log event to an issue
///
/// Events to process
/// Issue definition for this log event
public abstract bool HandleEvent(IssueEvent issueEvent);
///
/// Gets all the issues created by this handler
///
///
public abstract IEnumerable GetIssues();
}
///
/// Context object for issue handlers
///
public class IssueHandlerContext
{
///
/// Identifier for the current stream
///
public StreamId StreamId { get; }
///
/// Identififer of the template
///
public TemplateId TemplateId { get; }
///
/// Identifier for the current node name
///
public string NodeName { get; }
///
/// Annotations for this node
///
public IReadOnlyDictionary NodeAnnotations { get; }
///
/// Constructor
///
public IssueHandlerContext(StreamId streamId, TemplateId templateId, string nodeName, IReadOnlyDictionary nodeAnnotations)
{
StreamId = streamId;
TemplateId = templateId;
NodeName = nodeName;
NodeAnnotations = nodeAnnotations;
}
}
}