-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #868 from azist/wip
Wip #861 Facts, Type Hints, Bixon
- Loading branch information
Showing
29 changed files
with
2,453 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*<FILE_LICENSE> | ||
* Azos (A to Z Application Operating System) Framework | ||
* The A to Z Foundation (a.k.a. Azist) licenses this file to you under the MIT license. | ||
* See the LICENSE file in the project root for more information. | ||
</FILE_LICENSE>*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
using Azos.Apps.Injection; | ||
using Azos.Data; | ||
using Azos.Data.Business; | ||
using Azos.Log; | ||
using Azos.Serialization.Bix; | ||
|
||
namespace Azos.Sky.Chronicle | ||
{ | ||
[Bix("a06fb712-7e64-435e-8325-f28d67a544e3")] | ||
[Schema(Description = "Provides model for filtering log chronicles for facts")] | ||
public sealed class LogChronicleFactFilter : FilterModel<IEnumerable<Fact>> | ||
{ | ||
[Field(required: true, description: "Log message filter which facts are based on")] | ||
public LogChronicleFilter LogFilter { get; set; } | ||
|
||
[InjectModule] ILogChronicle m_Chronicle; | ||
|
||
protected async override Task<SaveResult<IEnumerable<Fact>>> DoSaveAsync() | ||
=> new SaveResult<IEnumerable<Fact>>(await m_Chronicle.GetFactsAsync(this).ConfigureAwait(false)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*<FILE_LICENSE> | ||
* Azos (A to Z Application Operating System) Framework | ||
* The A to Z Foundation (a.k.a. Azist) licenses this file to you under the MIT license. | ||
* See the LICENSE file in the project root for more information. | ||
</FILE_LICENSE>*/ | ||
|
||
using System; | ||
using Azos.Data; | ||
using Azos.Log; | ||
using Azos.Serialization.Bix; | ||
using Azos.Time; | ||
|
||
namespace Azos.IO.Archiving | ||
{ | ||
/// <summary> | ||
/// Appends into Azos fact binary archives | ||
/// </summary> | ||
[ContentTypeSupport(CONTENT_TYPE_FACTS)] | ||
public sealed class FactArchiveAppender : ArchiveBixAppender<Fact> | ||
{ | ||
public const string CONTENT_TYPE_FACTS = "bix/azfacts"; | ||
|
||
public FactArchiveAppender(IVolume volume, ITimeSource time, Atom app, string host, Action<Fact, Bookmark> onPageCommit = null) | ||
: base(volume, time, app, host, onPageCommit){ } | ||
|
||
protected override void DoSerializeBix(BixWriter wri, Fact entry) | ||
{ | ||
if (entry == null) | ||
{ | ||
wri.Write(false); //NULL | ||
return; | ||
} | ||
|
||
wri.Write(true); // NON-NULL | ||
wri.Write(entry.FactType); | ||
wri.Write(entry.Id); | ||
wri.Write(entry.RelatedId == Guid.Empty ? (Guid?)null : entry.RelatedId);//nullable Guid takes 1 byte instead of 16 | ||
wri.Write(entry.Gdid.IsZero ? (GDID?)null : entry.Gdid);//nullable Gdid will consume 1 byte instead of 12 zeros | ||
wri.Write(entry.Channel); | ||
wri.Write(entry.Topic); | ||
wri.Write(entry.Host); | ||
wri.Write(entry.App); | ||
wri.Write((int)entry.RecordType); | ||
wri.Write(entry.Source); | ||
wri.Write(entry.UtcTimestamp); | ||
Bixon.WriteObject(wri, entry.HasAmorphousData ? entry.AmorphousData : null); | ||
Bixon.WriteObject(wri, entry.Dimensions); | ||
Bixon.WriteObject(wri, entry.Metrics); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/*<FILE_LICENSE> | ||
* Azos (A to Z Application Operating System) Framework | ||
* The A to Z Foundation (a.k.a. Azist) licenses this file to you under the MIT license. | ||
* See the LICENSE file in the project root for more information. | ||
</FILE_LICENSE>*/ | ||
|
||
using System; | ||
|
||
using Azos.Data; | ||
using Azos.Log; | ||
using Azos.Serialization.Bix; | ||
using Azos.Serialization.JSON; | ||
|
||
namespace Azos.IO.Archiving | ||
{ | ||
/// <summary> | ||
/// Reads archives of Log.Fact items. The implementation is thread-safe | ||
/// </summary> | ||
[ContentTypeSupport(FactArchiveAppender.CONTENT_TYPE_FACTS)] | ||
public sealed class FactArchiveReader : ArchiveBixReader<Fact> | ||
{ | ||
public FactArchiveReader(IVolume volume, Func<Fact, Fact> factory = null) : base(volume) | ||
{ | ||
Factory = factory; | ||
} | ||
|
||
public readonly Func<Fact, Fact> Factory; | ||
|
||
[ThreadStatic] | ||
private static Fact ts_FactCache; | ||
|
||
public override Fact MaterializeBix(BixReader reader) | ||
{ | ||
if (!reader.ReadBool()) return null; | ||
|
||
Fact fact = null; | ||
|
||
if (Factory != null) | ||
{ | ||
fact = ts_FactCache; | ||
if (fact == null) | ||
{ | ||
fact = new Fact(); | ||
} | ||
} | ||
else | ||
{ | ||
fact = new Fact(); | ||
} | ||
|
||
fact.FactType = reader.ReadAtom(); | ||
fact.Id = reader.ReadGuid(); | ||
|
||
var guid = reader.ReadNullableGuid(); | ||
fact.RelatedId = guid.HasValue ? guid.Value : Guid.Empty; | ||
|
||
var gdid = reader.ReadNullableGDID(); | ||
fact.Gdid = gdid.HasValue ? gdid.Value : GDID.ZERO; | ||
|
||
fact.Channel = reader.ReadAtom(); | ||
fact.Topic = reader.ReadAtom(); | ||
fact.Host = reader.ReadString(); | ||
fact.App = reader.ReadAtom(); | ||
fact.RecordType = (MessageType)reader.ReadInt(); | ||
fact.Source = reader.ReadInt(); | ||
fact.UtcTimestamp = reader.ReadDateTime(); | ||
fact.SetAmorphousData(Bixon.ReadObject(reader) as JsonDataMap); | ||
fact.Dimensions = Bixon.ReadObject(reader) as JsonDataMap; | ||
fact.Metrics = Bixon.ReadObject(reader) as JsonDataMap; | ||
|
||
if (Factory != null) | ||
{ | ||
var result = Factory(fact); | ||
ts_FactCache = object.ReferenceEquals(result, fact) ? null : fact; | ||
return result; | ||
} | ||
|
||
return fact; | ||
} | ||
} | ||
} |
Oops, something went wrong.