Skip to content

Commit

Permalink
added interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sammychinedu2ky committed Nov 17, 2023
1 parent 7912831 commit 8ac695a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Consul/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ public class ConfigPayload
public string Name { get; set; }
public string Protocol { get; set; }
}
public class Config

public interface IConfig
{
public Task<WriteResult> ApplyConfig( ConfigPayload cp, CancellationToken ct = default)

}

public class Config : IConfig
{
public Task<WriteResult> ApplyConfig(ConfigPayload cp, CancellationToken ct = default)
{
return ApplyConfig(string.Empty, 0, cp, WriteOptions.Default, ct);
}
Expand All @@ -41,9 +47,9 @@ public Task<WriteResult> ApplyConfig(string dc, ConfigPayload cp, CancellationTo
return ApplyConfig(dc, 0, cp, WriteOptions.Default, ct);
}

public Task<WriteResult> ApplyConfig( int cas, ConfigPayload cp, CancellationToken ct = default)
public Task<WriteResult> ApplyConfig(int cas, ConfigPayload cp, CancellationToken ct = default)
{
return ApplyConfig(string.Empty, cas, cp, WriteOptions.Default, ct);
return ApplyConfig(string.Empty, cas, cp, WriteOptions.Default, ct);
}
public Task<WriteResult> ApplyConfig(string dc = "", int cas = 0, ConfigPayload cp, WriteOptions q, CancellationToken ct = default)
{
Expand All @@ -55,5 +61,5 @@ public Task<WriteResult> ApplyConfig(string dc = "", int cas = 0, ConfigPayload
}
}
}

}
34 changes: 34 additions & 0 deletions Consul/Interfaces/IConfigEndpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// -----------------------------------------------------------------------
// <copyright file="IConfigEndpoint.cs" company="G-Research Limited">
// Copyright 2020 G-Research Limited
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Consul.Interfaces
{
public interface IConfigEndpoint
{
Task<WriteResult> ApplyConfig(string dc = "", int cas = 0, ConfigPayload cp = null, WriteOptions q = null, CancellationToken ct = default);
Task<WriteResult> ApplyConfig(ConfigPayload cp, CancellationToken ct = default);
Task<WriteResult> ApplyConfig(int cas, ConfigPayload cp, CancellationToken ct = default);
Task<WriteResult> ApplyConfig(string dc, ConfigPayload cp, CancellationToken ct = default);
}
}

0 comments on commit 8ac695a

Please sign in to comment.