refactor(psk): Export transactions

This commit is contained in:
ieQu1 2022-08-18 14:19:50 +02:00
parent d906715e0a
commit fa12c66ad9
2 changed files with 8 additions and 3 deletions

View File

@ -2,7 +2,7 @@
{application, emqx_psk, [ {application, emqx_psk, [
{description, "EMQX PSK"}, {description, "EMQX PSK"},
% strict semver, bump manually! % strict semver, bump manually!
{vsn, "5.0.0"}, {vsn, "5.0.1"},
{modules, []}, {modules, []},
{registered, [emqx_psk_sup]}, {registered, [emqx_psk_sup]},
{applications, [kernel, stdlib]}, {applications, [kernel, stdlib]},

View File

@ -43,6 +43,11 @@
code_change/3 code_change/3
]). ]).
%% Internal exports (RPC)
-export([
insert_psks/1
]).
-record(psk_entry, { -record(psk_entry, {
psk_id :: binary(), psk_id :: binary(),
shared_secret :: binary(), shared_secret :: binary(),
@ -199,10 +204,10 @@ import_psks(SrcFile) ->
import_psks(Io, Delimiter, ChunkSize, NChunk) -> import_psks(Io, Delimiter, ChunkSize, NChunk) ->
case get_psks(Io, Delimiter, ChunkSize) of case get_psks(Io, Delimiter, ChunkSize) of
{ok, Entries} -> {ok, Entries} ->
_ = trans(fun insert_psks/1, [Entries]), _ = trans(fun ?MODULE:insert_psks/1, [Entries]),
import_psks(Io, Delimiter, ChunkSize, NChunk + 1); import_psks(Io, Delimiter, ChunkSize, NChunk + 1);
{eof, Entries} -> {eof, Entries} ->
_ = trans(fun insert_psks/1, [Entries]), _ = trans(fun ?MODULE:insert_psks/1, [Entries]),
ok; ok;
{error, {bad_format, {line, N}}} -> {error, {bad_format, {line, N}}} ->
{error, {bad_format, {line, NChunk * ChunkSize + N}}}; {error, {bad_format, {line, NChunk * ChunkSize + N}}};